Loading...

Thursday, 16 August 2012

Simple load URL (Android)

package test.app;

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 web = (WebView) findViewById(R.id.webview);         
        web.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/webview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
   
</LinearLayout>

No comments:

Post a Comment