Use WebView in Android to create an application

Source: Internet
Author: User

 

You can use WebView to add a WEB application to the client application. The WebView class is an extension of the View in Android. You can use it in the layout file of the Activity. It does not include any WEB browser development features, such as local control or address bar. WebView displays a WEB page by default.

 

The most common way to use WebView is to display information in the application, which is changed. Like a user agreement or help manual. In your application, you can create an Activity that contains WebView and use it to display an online document.

 

In another case, your application always obtains data from the network. For example, Email. In this case, it is more convenient to use WebView to load webpages.

 

Add a WebView to your application:

 

<? Xml version = "1.0" encoding = "UTF-8"?>

<WebView xmlns: android = "http://schemas.android.com/apk/res/android"

Android: id = "@ + id/webview"

Android: layout_width = "fill_parent"

Android: layout_height = "fill_parent"

/>

 

Load a page through LoadedUrl:

 

WebView myWebView = (WebView) findViewById (R. id. webview );

MyWebView. loadUrl (http://www.bkjia.com /);

 

Before that, you should write the following code in Mainifest to ensure Internet connection:

 

<Manifest...>

<Uses-permission android: name = "android. permission. INTERNET"/>

...

</Manifest>

From Yanyun's column

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.