how to add web view inside dialog or popup window.
my web view hold URL WebView.loadurl() .when view added inside dialog it still moving to the browser.
I've been in android loading webview in dialog but is no example of how to do it? thanks
Here is example:
AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Title here"); WebView wv = new WebView(this); wv.loadUrl("http:\\www.google.com"); 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();
You need to override setWebViewClient()..
mWebView = (WebView) view.findViewById(R.id.wv1); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false; } }); mWebView.loadUrl(mUrl);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With