Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetInitialScalesetWebChromeClientsetWebViewClient

0
public class ViewArticle extends Activity {
 
	public void onCreate(Bundle savedInstanceState) {
 
		super.onCreate(savedInstanceState);
		WebView webView=new WebView(this);
		setContentView(webView);
 
		//Code start--code taken from Android documentation for WebView  
		final Activity activity = this;
		webView.setWebChromeClient(new WebChromeClient() {
			public void onProgressChanged(WebView view, int progress) {
				// Activities and WebViews measure progress with different scales. 
				// The progress meter will automatically disappear when we reach 100% 
				activity.setProgress(progress * 1000);
			} 
		}); 
		webView.setWebViewClient(new WebViewClient() {
			public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
				Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
			} 
		}); 
		//end code borrowing from Android documentation 
 
		Bundle extras=getIntent().getExtras();
		String url=extras.getString(ArticleActivity.ARTICLE_SELECTED);
		 
		webView.getSettings().setBuiltInZoomControls(true);		
		webView.setInitialScale(50);
		 
		webView.getSettings().setLoadWithOverviewMode(true);
		webView.getSettings().setUseWideViewPort(true);
 
		final ProgressDialog dialog;
		 
		int stringId=R.string.Loading;
		String message=getString(stringId);
		dialog=ProgressDialog.show(ViewArticle.this, "", message, true);
		dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		dialog.setCancelable(false);
		 
		webView.setWebViewClient(new WebViewClient() {
 
			   public void onPageFinished(WebView view, String url) {
			        dialog.dismiss();
			    } 
			}); 
		 
		webView.loadUrl(url);
 
 
	} 
 
	/*public boolean onTouchEvent(MotionEvent ev)