Hello, WebView

A WebView allows you to Create your own Web Browser Activity. In this Tutorial, we'll Create a simple Activity that can View Web pages.

Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-webview.html

HelloWebView.java Code

1
  package com.example.test; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class HelloWebView extends Activity (WebView webview; / ** 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.getSettings (). setJavaScriptEnabled (true) ; webview.loadUrl (http://ditu.google.cn);))

Layout-> main.xml

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

Implementation of the Eclipse-> HelloWebViewAndroid-> Android Application Show pictures are as follows:

Code download HelloWebView.zip