When using EditText to display HTML strings, EditText does not parse any HTML tags, but instead displays all the HTML tags directly-----as if they were displayed in a regular Notepad, or if the application wants to re-parse the HTML string, As an HTML page to display, it is also possible.
WebView provides a loaddata (string data, String MimeType, String encoding) method that can be used to load and display HTML code, but during actual use, when it loads content containing Chinese HTML, the Web The view will display garbled characters.
WebView also provides a loaddatawithbaseurl (string baseUrl, String data, String MimeType, String encoding, String history URL) method, which is an enhanced version of the LoadData (string data, String MimeType, String encoding) method, which does not produce garbled characters.
1. Data: Specifies the HTML code that needs to be loaded.
2. MimeType: Specifies the MIME type of HTML code, which can be specified as text/html for HTML code.
3, Encoding: Specifies the character set used for HTML code encoding. For example, designated as GBK.
import android.os.bundle;import android.app.activity;import android.view.menu;import android.webkit.webview;public class viewhtml extends activity {WebView show; @Override protected void oncreate (bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.activity_view_html); Gets the WebView component show = (WebView) findviewbyid (r.id.show) in the program; Stringbuilder sb = new stringbuilder (); Stitching a section of HTML code sb.append ("
This article is from the "Liangxiao Technology Center" blog, please be sure to keep this source http://liangxiao.blog.51cto.com/3626612/1889694
Loading HTML code with WebView