Does AlertDialog support WebView?

匿名 (未验证) 提交于 2019-12-03 02:31:01

问题:

I am trying to implement a AlertDialog with a 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 got an error at "View alertDialogView = inflater.inflate(R.layout.dialog_layout, null);" say "android.view.InflateException: Binary XML file line #6: Error inflating class webView " and "11-26 17:15:47.934: ERROR/AndroidRuntime(4699): Caused by: java.lang.ClassNotFoundException: android.view.webView in loader dalvik.system.PathClassLoader@43457e60 "

Can anyone knows whats happened? Does AlertDialog support WebView? Thank you for any advice in advance.

Cheers, Chris

回答1:

You need to write WebView, not webView. Uppercase W



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!