Непосредственно поместите html-код в WebView (Android)
При использовании WebView мы обычно ставим для него URL-адрес:
WebView.loadUrl(myURL);
но можно напрямую разместить HTML-код? Так что это будет логично, что:
WebView.loadContent ( <html><head><script></script></head><body>....</body></html> );
Спасибо.
Ответы
Ответ 1
Проверьте это:
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);
Ответ 2
String yourhtmlpage = "<html><body>You scored <b>hello world</b> points.</body></html>";
webview.loadDataWithBaseURL(null, yourhtmlpage, "text/html", "UTF-8", null);
Ответ 3
Попробуйте этот код. Меня устраивает.
WebSettings settings = mDesc.getSettings();
settings.setDefaultTextEncodingName("utf-8");
mDesc.loadData(mDescText, "text/html; charset=utf-8",null);