UI Component: WebView

A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages.

In this demo, we get to view a web address in a totally different way by sidestepping the default browser and creating our own custom webviewer.

The key to creating the custom webviewer is the MyWebViewClient class that extends the WebViewClient class. With its key method shouldOverrideUrlLoading(view,url) that gives control to application when a new url is loaded in the provided view.

Sample Example

1) Create a new project/Activity called UIActivity.

2) We will have EditText in which URL to be entered, Button and WebView.

So Open the layout file. Insert following:

[sourcecode language=”xml”]