Question

I have a problem showing a webview when you touch one item from Listview. The alert dialog works fine but it doesn't show anything. I tried other ways to show but always the alert dialog is empty. Does Somebody know the way to show successful?

final AlertDialog.Builder detailsDialog = new AlertDialog.Builder(this);
        final LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);

        lstView1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v,
                                    int position, long id) {

                View layout = inflater.inflate(R.layout.custom_fullimage_dialog,
                        (ViewGroup) findViewById(R.id.layout_root));

                webView = (WebView) layout.findViewById(R.id.webkit);

                webView.loadUrl("http:\\www.google.co.uk");

                detailsDialog.setView(layout);
                detailsDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }

                });

                detailsDialog.create();
                detailsDialog.show();



            }
        });
Was it helpful?

Solution

Here's an example of loading a WebView in a Dialog. It looks like you might be inflating yours incorrectly.

    final WebView webView = new WebView(this);
    webView.loadUrl("http:\\www.google.co.uk");
    new AlertDialog.Builder(this)
            .setTitle("Title")
            .setView(webView)
            .setPositiveButton(android.R.string.ok, null)
            .show();

Results

Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top