Jul 20, 2011

android.webkit.WebView

android.webkit.WebView displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.

example:

android.webkit.WebView

package com.AndroidWebView;


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

public class AndroidWebViewActivity extends Activity {

WebView webView;
final String DEFAULT_URL = "http://android-coding.blogspot.com/?m=1";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView)findViewById(R.id.webview);
webView.loadUrl(DEFAULT_URL);

}
}


<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>


next:
- More on WebView, override url loading

No comments:

Post a Comment

Infolinks In Text Ads