Add a client to the web view : WebView « UI « Android






Add a client to the web view

   

package app.test;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Test extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webview = new WebView(this);
    webview.getSettings().setJavaScriptEnabled(true);
    // 
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl("http://www.google.com");
    setContentView(webview);
  }
}

   
    
    
  








Related examples in the same category

1.Adding WebView to Activity, load URL and grab focus
2.Load local resource into WebView
3.Enable Javascript for WebView
4.Load remote web page for WebView
5.extends WebViewClient and check the url
6.Using WebView to load url
7.Using WebView to load static html string
8.Load static html file into WebView
9.Load Url to WebView
10.Load image from remote host to WebView
11.Sample creating 10 webviews.