Transferred from: http://blog.sina.com.cn/s/blog_5da93c8f0101p4y8.html
The recent project to use WebView load a piece of HTML text, using the WebView loaddata (detail, "text/html", "UTF-8"), the test found that the Chinese garbled, found the answer on Google. Change to LoadData (data, "text/html; Charset=utf-8 ", null); it's not garbled.
The reasons are as follows:
If you use Loaddatawithbaseurl, if you do not pass in the URL, the refresh will cause a white screen, because the refresh is called the Reload method, reload is based on the incoming URL to reload once again Loadurl (URL), do not pass in the URL, The default URL is About:blank
You can use LoadData, refresh is only from the cache, but in more than 4.0, if the API is written in the LoadData (data, "UTF-8", null), the time will be garbled, if written loaddata (data, "text/html; Charset=utf-8 ", null); LoadData The final mechanism is to put the incoming three parameters together, and then Loadurl operation, the parameter is data," text/html; Charset=utf-8 ", null these three are assembled, joined text/html; Charset=utf-8 is equivalent to restricting the character of the page
Today, when testing, found Mwebview.loaddata (detail, "text/html;charset=utf-8", null); In the millet one s still exist in the case of Chinese garbled, changed to Webview.loaddatawithbaseurl (NULL, detail, "text/html", "UTF-8", null); There's no problem. Specific reasons have not been found, if you know the classmate, I hope you can @ me!
WebView LoadData garbled problem