Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetScrollBarStylesetWebChromeClientsetWebViewClient, setHorizontalScrollBarEnabled

0
	private void initView() 
	{ 
		LinearLayout contentView=new LinearLayout(this);
		contentView.setBackgroundColor(Color.WHITE);
		LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
		mWebView=new WebView(this);
		contentView.addView(mWebView,params);
		setContentView(contentView);
		 
		WebViewCookieUtil.clearCookies(this);
		 
		mWebView.setHorizontalScrollBarEnabled(true);
		mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY) ;//去掉右边白色边框
		 
		WebSettings mWebSettings = mWebView.getSettings();
		mWebSettings.setJavaScriptEnabled(true);
		mWebSettings.setSupportZoom(true);
		mWebSettings.setBuiltInZoomControls(true);// 设置支持缩放
		mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
		 
		pd = new ProgressDialog(AuthorizeActivity.this);
		pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		pd.setMessage("数据加载中,请稍后!");
		pd.show();
		 
		WebViewClient client=WebViewClientFactory.produce(extra_open_Dest,AuthorizeActivity.this);
		mWebView.setWebViewClient(client);
		 
		mWebView.setWebChromeClient(new WebChromeClient()
		{ 
 
			@Override 
			public void onProgressChanged(WebView view, int newProgress)
			{ 
				if (newProgress == 100 && pd != null)
				{ 
					pd.hide();
				} 
				super.onProgressChanged(view, newProgress);
			} 
		}); 
		mWebView.loadUrl(extra_uri);
	} 
	 
	@Override 
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{