Load Url to WebView : WebView « UI « Android






Load Url to WebView

   
package app.test;

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

public class Test extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        
        
        WebView wv = (WebView) findViewById(R.id.webview1);          
        wv.loadUrl("http://www.google.com"); 
        
       
    }
    
    private class Callback extends WebViewClient {
      @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      return(false);
    }
  }  
}

//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<WebView android:id="@+id/webview1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
    
</LinearLayout>

   
    
    
  








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 image from remote host to WebView
10.Add a client to the web view
11.Sample creating 10 webviews.