六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 35|回复: 0

Eclipse 开发 Android, Hello, WebView (学习6)

[复制链接]

升级  2%

58

主题

58

主题

58

主题

举人

Rank: 3Rank: 3

积分
206
 楼主| 发表于 2013-1-15 02:47:16 | 显示全部楼层 |阅读模式
Hello, WebView

<div class="jd-descr">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 显示图片如下:
 
 
 
代码下载 HelloWebView.zip
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表