【发布时间】:2015-12-21 05:18:06
【问题描述】:
字符串包含 html 页面代码。根据要求,最好不要存储在文件中。如何在 Webview 中表示?
【问题讨论】:
-
到目前为止你做了什么?
字符串包含 html 页面代码。根据要求,最好不要存储在文件中。如何在 Webview 中表示?
【问题讨论】:
您好,如果您的字符串包含 html 页面代码,那么您可以直接在 Webview 中加载,如下所示。
webView.loadData(webData, "text/html; charset=UTF-8", null);
【讨论】:
试试这个:
WebView wv = (WebView)this.findViewById(R.id.myWebView);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadDataWithBaseURL(null, /*Your HTML string*/, "text/html", "utf-8", null);
【讨论】:
看看这个:http://developer.android.com/reference/android/webkit/WebView.html
String summary = "<html><body>Your <b>HTML</b> code.</body></html>";
webview.loadData(summary, "text/html", null);
更多参考请检查这个答案..
【讨论】: