我通过变量在响应中获取此 html 内容:String mresult=
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Lorem Ipsum</title>
</head>
<body style="width:300px; color: #00000; ">
<p><strong> About us</strong> </p>
<p><strong> Lorem Ipsum</strong> is simply dummy text .</p>
<p><strong> Lorem Ipsum</strong> is simply dummy text </p>
<p><strong> Lorem Ipsum</strong> is simply dummy text </p>
</body></html>
它无法加载webview
,我必须尝试像这样加载它:
web.loadDataWithBaseURL(null, mresult, "text/html", "UTF-8", null);
仍然webview
显示空白白页。
在xml
文件中:
<WebView
android:id="@+id/wV"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dp"
android:background="@android:color/transparent"
android:cacheColorHint="#00000000" />
在活动中:
String mresult="Here my given data";
WebView web = (WebView)findViewById(R.id.wV);
web.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
web.loadData(mresult, "text/html; charset=UTF-8", null);