分享到:

西安雁塔兆隆计算机培训中心西安软件开发,西安java培训,全国领先的软件开发培训

联系资料

西安雁塔兆隆计算机培训中心
所在地区:
陕西省 西安市
公司主页:
暂无
电话号码:
029-*******
传真号码:
暂无
联 系 人:
王老师
移动电话:
1592*******
电子邮箱:
暂无

Android——WebView组件的使用详解

发布于 2013年01月13日

[摘要]通过本专题的讲解可以了解到WebView组件的详细使用: 网络内容 1、LoadUrl直接显示网页内容(单独显示网络图片) 2、LoadData显示中文网页内容(含空格的处理) APK包内文件 1、LoadUrl显示APK中Html和图片文件 2、LoadData(loadDataWithBaseURL)显示APK中图片和

通过本专题的讲解可以了解到WebView组件的详细使用:

网络内容

1、LoadUrl直接显示网页内容(单独显示网络图片)

2、LoadData显示中文网页内容(含空格的处理)

APK包内文件

1、LoadUrl显示APK中Html和图片文件

2、LoadData(loadDataWithBaseURL)显示APK中图片和文字混合的Html内容

res/layout/***

Xml代码

< ?xml version="1.0" encoding="utf-8"?>

< LINEARLAYOUT android:layout_height="fill_parent" android:layout_width="fill_parent"android:orientation="vertical" xmlns:android="***/res/android">

< WEBVIEW android:layout_height="fill_parent" android:layout_width="fill_parent"android:id="@+id/webview" />

< /LINEARLAYOUT>

< ?xml version="1.0" encoding="utf-8"?>

< LINEARLAYOUT android:layout_height="fill_parent" android:layout_width="fill_parent"android:orientation="vertical" xmlns:android="***/res/android">

< WEBVIEW android:layout_height="fill_parent" android:layout_width="fill_parent"android:id="@+id/webview" />

< /LINEARLAYOUT>

Example_***

Java代码

package ***rks;

import ***oder;

import ***ty;

import ***;

import ***w;

public class Example_webview extends Activity {

WebView webView;

final String mimeType = "text/html";

final String encoding = "utf-8";

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

***te(savedInstanceState);

setContentView(***);

webView = (WebView) findViewById(***w);

***tings().setJavaScriptEnabled(true);

(责任编辑:)