TrinityTuts Tips

Add Webview inside AlertDialog View Android

In this, Tip i will explain to you how to add Webview in your AlertDialog Android Application. To add Web View inside Dialog please use below code. This is working fine I use this in my E-commerce Application {offloo.com}

AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("Title here");

WebView wv = new WebView(this);
wv.loadUrl("\*Your Web Link *\");
wv.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);

        return true;
    }
});

alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int id) {
        dialog.dismiss();
    }
});
alert.show();

Hope this sample code help you 🙂 please like and share my social page.