Web视图如何加载HTML内容? [英] how does web view Load Html Content?
本文介绍了Web视图如何加载HTML内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过以下变量在String mresult=
I am getting this html content in Response via the variable: 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
中加载,我必须尝试像这样加载它:
It could not load in webview
, I have to try to load it like this:
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);
推荐答案
y仍然不将其不加载到webview
中,但是给定的结果以TextView
的形式显示在TextView
中,例如
don't know y still it not loading in webview
but given result is display in TextView
in Html
format like
TextView txtweb = (TextView) findViewById(R.id.txtweb);
txtweb.setText(Html.fromHtml(mresult));
这篇关于Web视图如何加载HTML内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文