Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WebView newsContent = (WebView) findViewById(R.id.news_content);
- newsContent.getSettings().setJavaScriptEnabled(true);
- newsContent.getSettings().setLoadWithOverviewMode(true);
- newsContent.getSettings().setUseWideViewPort(true);
- newsContent.loadUrl("http://www.ptinews.com/news/9168439_Aadhaar-linkage-with-bank-accounts-mandatory--says-RBI.html");
- <uses-permission android:name="android.permission.INTERNET" />
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/activity_web_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- tools:context="com.example.dhruv.demoapiaitutorial.WebVIewActivity">
- <WebView
- android:id="@+id/webview"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </RelativeLayout>
- package com.example.dhruv.demoapiaitutorial;
- import android.app.ProgressDialog;
- import android.graphics.Bitmap;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.webkit.WebChromeClient;
- import android.webkit.WebView;
- import android.webkit.WebViewClient;
- import android.widget.Toast;
- public class WebVIewActivity extends AppCompatActivity {
- private WebView mWebview;
- private ProgressDialog dialog; //creating object of progress dialog
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_web_view);
- dialog = new ProgressDialog(this);
- dialog.setMessage("Please wait, your web is being open...");
- dialog.setCancelable(false);
- mWebview = (WebView) findViewById(R.id.webview);
- mWebview.setWebViewClient(new WebViewClient() {
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- super.onPageStarted(view, url, favicon);
- /*Showing progress dialog*/
- dialog.show();
- }
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
- /*You can also access url in this overridden method*/
- /*closing progress dialog*/
- dialog.dismiss();
- }
- });
- mWebview.getSettings().setJavaScriptEnabled(true);
- mWebview.getSettings().setLoadWithOverviewMode(true);
- mWebview.getSettings().setUseWideViewPort(true);
- mWebview.loadUrl("http://www.ptinews.com/news/9168439_Aadhaar-linkage-with-bank-accounts-mandatory--says-RBI.html");
- }
- }
Add Comment
Please, Sign In to add comment