WebView in dialog

I have an application where I need to load a small web page inside a webview. Web browsing must be loaded inside the dialog box. I tried to implement it; but every time an empty dialog loads and doesn't seem to contain content inside it. The code I used is below

Uri uri = Uri.parse(item.getLink()); Dialog dialog = new Dialog(this); LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.webviewdialog, null); dialog.setContentView(v); dialog.setCancelable(true); WebView wb = (WebView) v.findViewById(R.id.webView1); wb.loadUrl(uri.toString()); dialog.show(); 

I also tried pasting the urls directly into loadUrl, but I am getting the same problem.

Any help would be appreciated.

+8
android android-webview android-dialog
source share
2 answers

Try the following:

  WebView webView = new WebView(this); webView.loadUrl("http://www.google.com/"); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setView(webView); dialog.setPositiveButton("Okay", null); dialog.show(); 
+14
source share

Try using a custom webview dialog.
Here is one example on how to do this.

0
source share

All Articles