Android.webkit.WebView itself is a browser implementation, and its kernel is based on the open source WebKit engine.
Common methods:
void GoBack (): Back
void GoForward (): Forward
void Loadurl (String URL): Load Web page
Boolean zoomin (): Enlarge Web page
Boolean zoomout (): Shrinking Web page
For more information, please refer to the official documentation (DOCS/REFERENCE/ANDROID/WEBKIT/WEBVIEW.HTML)
1. Load the URL corresponding to the page
WebView webview = (WebView) findViewById(R.id.webview);...webview.loadUrl("www.csdn.net");
2. Loading HTML code
WebView provides Loaddatawithbaseurl (string baseUrl, String data, String MimeType, String encoding, String Historyurl) methods, The parameters are described as follows:
baseUrl:作为网页输入的网址(一般null)data:需要加载的HTML代码mimeType:指定HTML代码的MIME类型,HTML可指定为text/htmlencoding:指定HTML代码的字符编码historyUrl:历史输入的网址(一般null)
WebView WebView = (WebView) Findviewbyid (R. ID. WebView);StringBuilder sb = new StringBuilder ();Stitching a piece of HTML code SB. Append(");Sb. Append(");Sb. Append("<title> Test </title>");Sb. Append(");Sb. Append("<body>");Sb. Append(");Sb. Append("</body>");Sb. Append(");Using a simple LoadData method can result in garbled//WebView. LoadData(SB. toString(),"Text/html","Utf-8");Load, and display HTML code WebView. Loaddatawithbaseurl(NULL, SB. toString(),"Text/html","Utf-8", null);
3. Through the WebView and JS interaction
See article: http://blog.csdn.net/smartbetter/article/details/51089613
Android Development Practice WebView