Getting Started in Android Development Part 21 - The WebView Layout
Home Tutorials Hints & Tips About

Android Apps and Training

Share on Facebook Share on Twitter

Getting Started in Android Development

Part 21 - The WebView Layout

As the name implies, the WebView is an Android view that allows webpages or HTML files to be displayed within the layout. The basic code to add a WebView to an XML layout is shown below:

<WebView
   android:id="@+id/WebView1"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />


In the video associated with this tutorial we simply construct a layout to build a very basic browser. It comprises an EditText field, a “go” button and the WebView itself. A screenshot of the resultant layout is shown below:

The basic android webview layout

Before the WebView will function you have to give the app permission to use the device's Internet service. This is done by modifying the Android Manifest file as shown below:


The next tutorial focuses on adding the Java code to complete the WebView functionality.

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

Permissions are used by the market place to inform the user what services the app will use.

After this tutorial your WebViewActivity.java file will look similar to the one below:

After this tutorial your activity_webview.xml layout file will look similar to the one below:

After this tutorial your ListviewActivity.java file will look similar to the one below:

After this tutorial your Android Manifest file will look similar to the one below:


Download Download tutorial set 1

© 2015 North Border Software All rights reserved
Privacy and Cookies Terms of Use Disclaimer Copyright
North Border Software Logo

North Border Software