Thursday, 10 November 2011

WEB VIEW

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

public class WebviewActivity extends Activity {
    WebView wv;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        wv =(WebView)findViewById(R.id.webView1);
        WebSettings ws = wv.getSettings();
// it is used for web setting like zoom in n out etc.
        ws.setBuiltInZoomControls(true);
// IT IS used for zoom in n zoom out.
        wv.loadUrl("http://www.google.com");
// IMP---- in androidmainfest.xml file jus give the permissions for acces INTERNET...
// FOR this just  click on androidmainfest.xml file n on permission tab just select USES PERMISSION AND THEN ADD INTERNET PERMISSION..

    }
}


XML FILE


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

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

No comments:

Post a Comment