Code example for WebSettings

Methods: setJavaScriptCanOpenWindowsAutomatically, setJavaScriptEnabled, setSupportZoom

0
		// 
		final WebView mWebView = new WebView(this);
		mWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 200));
		mWebView.setVerticalScrollbarOverlay(true);
		final WebSettings settings = mWebView.getSettings();
		settings.setSupportZoom(true);
		//WebView启用Javascript脚本执行 
		settings.setJavaScriptEnabled(true);
		settings.setJavaScriptCanOpenWindowsAutomatically(true);
		//映射Java对象到一个名为”js2java“的Javascript对象上 
		//JavaScript中可以通过"window.js2java"来调用Java对象的方法 
		mWebView.addJavascriptInterface(new JSInvokeClass(), "HTMLOUT");
		mWebView.loadUrl("http://www.baidu.com");
		layout.addView(mWebView);
		// 
		btn = new Button(this);
		btn.setText("show html");
		btn.setOnClickListener(new OnClickListener() {
			@Override 
			public void onClick(View v) {
				mWebView.loadUrl("javascript:window.HTMLOUT.showHtml(document.documentElement.innerHTML);");