Does AlertDialog support WebView?

I am trying to implement AlertDialog with Webview inside.

public OnClickListener imageButtonViewOnClickListener = new OnClickListener() {
public void onClick(View v) {

    LayoutInflater inflater = LayoutInflater.from(MyActivity.this);

    // error here
    View alertDialogView = inflater.inflate(R.layout.alert_dialog_layout, null);

    WebView myWebView = (WebView) findViewById(R.id.DialogWebView);
    myWebView.loadData(webContent, "text/html", "utf-8");
    AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
    builder.setView(alertDialogView);

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    }).show();
}

};

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<webView android:id="@+id/DialogWebView" android:layout_height="wrap_content"
    android:layout_width="fill_parent" android:layout_marginLeft="20dip"
    android:layout_marginRight="20dip" android:textAppearance="?android:attr/textAppearanceMedium" />

However, I received the error message "View alertDialogView = inflater.inflate (R.layout.dialog_layout, null);" say "android.view.InflateException: binary line of XML file # 6: error inflating the webView class" and "11-26 17: 15: 47.934: ERROR / AndroidRuntime (4699): caused by: java.lang.ClassNotFoundException: android.view. webView in the loader dalvik.system.PathClassLoader@43457e60 "

Does anyone know what happened? Does AlertDialog support WebView? Thanks for any advice in advance.

Cheers, Chris

+3
source share
1

WebView, webView. W

+8

Source: https://habr.com/ru/post/1777014/


All Articles