Eclipse 开发 Android, Hello, WebView (学习6)
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.
学习地址:http://androidappdocs.appspot.com/guide/tutorials/views/hello-webview.html
HelloWebView.java 代码
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
<?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>
执行 Eclipse->HelloWebViewAndroid->Android Application 显示图片如下:

这样的帖子,网上S一下,一大堆...
为什么这样写显示不出来
谁评的新手贴啊?虽然我不玩Android,但是Android还在起步阶段吧,资料应该是比较少的,发发这种帖子我觉得没什么不好啊