Android Development notes-webview

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.