Guest User

Untitled

a guest
Feb 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. webView = (WebView)v.findViewById(R.id.webView);
  2. webView.getSettings().setJavaScriptEnabled(true);
  3. webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  4. webView.getSettings().setDomStorageEnabled(true);
  5.  
  6.  
  7. webView.setWebChromeClient(new WebChromeClient(){
  8.  
  9. public void onProgressChanged(WebView view, int progress) {
  10. getActivity().setTitle("Loading...");
  11. getActivity().setProgress(progress * 100);
  12. if(progress == 100)
  13. getActivity().setTitle("2Mummy");
  14. }
  15. });
  16.  
  17. webView.loadUrl("http://my_url_here");
  18.  
  19. webView.setOnKeyListener(new View.OnKeyListener(){
  20.  
  21. public boolean onKey(View v, int keyCode, KeyEvent event) {
  22. if (keyCode == KeyEvent.KEYCODE_BACK
  23. && event.getAction() == MotionEvent.ACTION_UP
  24. && webView.canGoBack()) {
  25. handler.sendEmptyMessage(1);
  26. return true;
  27. }
  28.  
  29. return false;
  30. }
  31.  
  32. });
  33.  
  34. webView.setWebViewClient(new WebViewClient() {
  35. public boolean shouldOverrideUrlLoading(WebView view, String url){
  36.  
  37. view.loadUrl(url);
  38. if ((webView.canGoBack()) || (url!=url)){
  39.  
  40. }
  41. else{
  42.  
  43. }
  44. return false;
  45. }
  46.  
  47. @Override
  48. public void onPageStarted(WebView view, String url, Bitmap favicon){
  49.  
  50. }
  51.  
  52. @Override
  53. public void onPageFinished(WebView view, String url){
  54.  
  55. webView.setVisibility(View.VISIBLE);
  56. }
  57.  
  58. });
  59. webView.scrollTo(0,webView.getContentHeight());
  60.  
  61. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  62. xmlns:tools="http://schemas.android.com/tools"
  63. android:layout_width="match_parent"
  64. android:layout_height="match_parent"
  65. android:id="@+id/categoriesfrag"
  66. tools:context="com.quadcircles.tomummy.Fragment.Categories">
  67.  
  68. <WebView
  69. android:layout_width="match_parent"
  70. android:layout_height="match_parent"
  71. android:id="@+id/webView"/>
Add Comment
Please, Sign In to add comment