Webview is mainly used to develop Web applications. It is relatively simple. Declare a webview object in the layout file and call it in the activity.
Through the webview. loadurl ("Address") function you can open the corresponding link, such as webview. loadurl ("http://www.baidu.com /"). However, click the hyperlink on the page.
Will automatically jump to the default browser to open, in order to force the current webview to open the link can define a class that inherits webviewclient, such:
Private class webviewclientdemo extends webviewclient
{
Public Boolean shouldoverrideurlloading (webview view, string URL)
{// Display the page in webview instead of the default browser
View. loadurl (URL );
Return true;
}
Use the shouldoverrideurlloading () method, and then use webview. setwebviewclient (New webviewclientdemo ();
Please note that the above are ready or can not open the link, will appear "can not find the web page, http://www.xxxxx.com /? The webpage at XXXXXXXX may be temporarily faulty,
It may have been permanently moved to a new network address.
In this case, first check whether the device has a signal and Data Link. If the connection is normal, the related permissions are not configured and must be configured in the mainfest. xml file.
The permission "android. Permission. Internet" must be used in androidmanifest. xml; otherwise, the web page not available error may occur.
Add <uses-Permission Android: Name = "android. Permission. Internet"/> to the <manifest> node, which must be added after the application tag.