Guest User

Untitled

a guest
Oct 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. WebView newsContent = (WebView) findViewById(R.id.news_content);
  2. newsContent.getSettings().setJavaScriptEnabled(true);
  3. newsContent.getSettings().setLoadWithOverviewMode(true);
  4. newsContent.getSettings().setUseWideViewPort(true);
  5. newsContent.loadUrl("http://www.ptinews.com/news/9168439_Aadhaar-linkage-with-bank-accounts-mandatory--says-RBI.html");
  6.  
  7. <uses-permission android:name="android.permission.INTERNET" />
  8.  
  9. <?xml version="1.0" encoding="utf-8"?>
  10. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  11. xmlns:tools="http://schemas.android.com/tools"
  12. android:id="@+id/activity_web_view"
  13. android:layout_width="match_parent"
  14. android:layout_height="match_parent"
  15. android:paddingBottom="@dimen/activity_vertical_margin"
  16. android:paddingLeft="@dimen/activity_horizontal_margin"
  17. android:paddingRight="@dimen/activity_horizontal_margin"
  18. android:paddingTop="@dimen/activity_vertical_margin"
  19. tools:context="com.example.dhruv.demoapiaitutorial.WebVIewActivity">
  20.  
  21. <WebView
  22. android:id="@+id/webview"
  23. android:layout_width="match_parent"
  24. android:layout_height="match_parent" />
  25.  
  26. </RelativeLayout>
  27.  
  28. package com.example.dhruv.demoapiaitutorial;
  29.  
  30. import android.app.ProgressDialog;
  31. import android.graphics.Bitmap;
  32. import android.support.v7.app.AppCompatActivity;
  33. import android.os.Bundle;
  34. import android.webkit.WebChromeClient;
  35. import android.webkit.WebView;
  36. import android.webkit.WebViewClient;
  37. import android.widget.Toast;
  38.  
  39. public class WebVIewActivity extends AppCompatActivity {
  40.  
  41. private WebView mWebview;
  42. private ProgressDialog dialog; //creating object of progress dialog
  43.  
  44. @Override
  45. protected void onCreate(Bundle savedInstanceState) {
  46. super.onCreate(savedInstanceState);
  47. setContentView(R.layout.activity_web_view);
  48.  
  49. dialog = new ProgressDialog(this);
  50. dialog.setMessage("Please wait, your web is being open...");
  51. dialog.setCancelable(false);
  52.  
  53. mWebview = (WebView) findViewById(R.id.webview);
  54.  
  55. mWebview.setWebViewClient(new WebViewClient() {
  56. @Override
  57. public void onPageStarted(WebView view, String url, Bitmap favicon) {
  58. super.onPageStarted(view, url, favicon);
  59. /*Showing progress dialog*/
  60. dialog.show();
  61. }
  62.  
  63. @Override
  64. public void onPageFinished(WebView view, String url) {
  65. super.onPageFinished(view, url);
  66.  
  67. /*You can also access url in this overridden method*/
  68. /*closing progress dialog*/
  69. dialog.dismiss();
  70. }
  71. });
  72.  
  73.  
  74. mWebview.getSettings().setJavaScriptEnabled(true);
  75. mWebview.getSettings().setLoadWithOverviewMode(true);
  76. mWebview.getSettings().setUseWideViewPort(true);
  77. mWebview.loadUrl("http://www.ptinews.com/news/9168439_Aadhaar-linkage-with-bank-accounts-mandatory--says-RBI.html");
  78.  
  79. }
  80.  
  81. }
Add Comment
Please, Sign In to add comment