Directly put html code in a WebView (Android)

后端 未结 3 922
悲&欢浪女
悲&欢浪女 2021-02-06 23:18

While using WebView, we usually put a URL for it:

WebView.loadUrl(myURL);

but it is possible to put HTML code directly?? So that it will be in

3条回答
  •  梦如初夏
    2021-02-06 23:43

    Try this code. It works for me.

    WebSettings settings = mDesc.getSettings();
    settings.setDefaultTextEncodingName("utf-8");
    mDesc.loadData(mDescText, "text/html; charset=utf-8",null);
    

提交回复
热议问题