您的位置:首页 > 移动开发

实现应用WebView组件加载使用HTML代码添加的帮助信息

2016-01-18 20:19 666 查看
1、布局文件

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

<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>


2、MainActivity的onCreate()方法中

WebView webview = (WebView)findViewById(R.id.webView1);//获取布局管理器中添加的WebView组件
StringBuilder sb = new StringBuilder();//创建一个字符串构建器,将要显示的HTML内容放置在该构建器中
sb.append("<div>选择选项,然后从以下选项中进行选择:</div>");
sb.append("<ul>");
sb.append("<li>编辑内容:用于增加、移动和删除桌面上的快捷工具。</li>");
sb.append("<li>隐藏内容:用于隐藏桌面上的小工具。</li>");
sb.append("<li>显示内容:用于显示桌面上的小工具。</li>");
sb.append("</ul>");
webview.loadDataWithBaseURL(null, sb.toString(), "text/html", "utf-8", null);//加载数据


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: