Course Content

Course Content

Description

WebView in Android

 

In this video we are going to see that what is WebView.

Till now we have use different kind of layouts like Linear, Relative, Fragments etc...

If we want to add browser functionality in the application we can use WebView. It can load HTML in our application easily. To create applications that access internet connections we use WebView.

Suppose if we want to perform Google search from our application, than we can simply do that by loading WebView,

<WebView

xmlns:android="https://schemas.android.com/apk/res/android"

android:id="@+id/webview"

android:layout_width="fill_parent"

android:layout_height="fill_parent"/>

WebView will be more appropriate widget, as it can handle a much wider range of HTML tags. It also helps use JavaScript and CSS in our Android applications.

In order to load a web URL into the WebView, you need to call a method loadUrl(String url) of the WebView class, specifying the required url.

Syntax :

browser.loadUrl("http://www.google.com");

Apart from just loading URL you can have more control over your WebView by using the methods defined in WebView class.

WebView also has different methods like, canGoBack() to specify the webView has a back history item, canGoForward() to clear the webView forward and backward history, destroy() to destroy the internal state of webView and etc...

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere