Android WebView Example Tutorial | অ্যান্ড্রয়েড ওয়েবভিউ টিউটোরিয়াল |

Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity.

Android WebView Example Tutorial

Android WebView uses webkit engine to display web page.

The android.webkit.WebView is the subclass of AbsoluteLayout class.

Android WebView Example

Let’s see the simple code to display web page using web view.

Fast AndroidManifest.xml

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


WebView mywebview = (WebView) findViewById(;  mywebview.loadUrl("");  

Let’s see the simple code to display HTML web page using web view. In this case, html file must be located inside the asset directory.

WebView mywebview = (WebView) findViewById(;  mywebview.loadUrl("file:///android_asset/myresource.html");  

Let’s see another code to display HTML code of a string.

String data = "<html><body><h1>Hello, Javatpoint!</h1></body></html>";  mywebview.loadData(data, "text/html", "UTF-8");  

Complete Android WebView Example

File: activity_main.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=""    xmlns:tools=""    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.example.application.webviewapp.MainActivity">     <WebView        android:id="@+id/webview"        android:layout_width="match_parent"        android:layout_height="match_parent" /> </RelativeLayout>


Activity class

import android.webkit.WebSettings;import android.webkit.WebView;import android.webkit.WebViewClient; public class MainActivity extends AppCompatActivity {    private WebView webView;     @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);         webView = (WebView) findViewById(;        webView.setWebViewClient(new WebViewClient());        webView.loadUrl("");         WebSettings webSettings = webView.getSettings();        webSettings.setJavaScriptEnabled(true);    }     @Override    public void onBackPressed() {        if (webView.canGoBack()) {            webView.goBack();        } else {            super.onBackPressed();        }    }}



Action Bar  Hide Main Activity.







@Override    public void onBackPressed() {        if (webView.canGoBack()) {            webView.goBack();        } else {            super.onBackPressed();        }


একটি মন্তব্য পোস্ট করুন

নবীনতর পূর্বতন