【发布时间】:2012-12-09 18:14:42
【问题描述】:
在使用 WebView 时,我们通常会为其添加一个 URL:
WebView.loadUrl(myURL);
但是可以直接放HTML代码吗??所以它的逻辑是:
WebView.loadContent ( <html><head><script></script></head><body>....</body></html> );
谢谢。
【问题讨论】:
在使用 WebView 时,我们通常会为其添加一个 URL:
WebView.loadUrl(myURL);
但是可以直接放HTML代码吗??所以它的逻辑是:
WebView.loadContent ( <html><head><script></script></head><body>....</body></html> );
谢谢。
【问题讨论】:
看看这个: http://developer.android.com/reference/android/webkit/WebView.html
// OR, you can also load from an HTML string:
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);
【讨论】:
String yourhtmlpage = "<html><body>You scored <b>hello world</b> points.</body></html>";
webview.loadDataWithBaseURL(null, yourhtmlpage, "text/html", "UTF-8", null);
【讨论】:
试试这个代码。这个对我有用。
WebSettings settings = mDesc.getSettings();
settings.setDefaultTextEncodingName("utf-8");
mDesc.loadData(mDescText, "text/html; charset=utf-8",null);
【讨论】: