Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetScrollBarStylesetWebViewClient, requestFocus, setOnTouchListener

0
        Log.d(TAG, ipAddress);
		String host = ipAddress;
		int port = 8888;
        String urlPrefix = "http://" + host + ":" + Integer.toString(port) + "/";
        String attachURL = urlPrefix + "touchapp/doc1/index.html";
        webView = new WebView(TouchAppActivity.this);
        webView.setWebViewClient(new CustomWebViewClient());		
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		webView.getSettings().setDomStorageEnabled(true);
 
		webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
 
		webView.requestFocus(View.FOCUS_DOWN);
	    webView.setOnTouchListener(new View.OnTouchListener() {
	        @Override 
	        public boolean onTouch(View v, MotionEvent event) {
	            switch (event.getAction()) {
	                case MotionEvent.ACTION_DOWN:
	                case MotionEvent.ACTION_UP:
	                    if (!v.hasFocus()) {
	                        v.requestFocus();
	                    } 
	                    break; 
	            } 
	            return false; 
	        } 
	    }); 
        setContentView(R.layout.main);
		setContentView(webView);
		webView.loadUrl(attachURL);
    } 
     
	private class CustomWebViewClient extends WebViewClient {
		@Override 
		public boolean shouldOverrideUrlLoading(WebView view, String url) {