AlertDialog是否支持WebView?

时间:2010-11-26 06:38:33

标签: android webview alertdialog

我正在尝试使用Webview实现AlertDialog。

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" />

但是,我在“查看alertDialogView = inflater.inflate(R.layout.dialog_layout,null)”时遇到错误;“说“android.view.InflateException:二进制XML文件行#6:错误膨胀类webView “和”11-26 17:15:47.934:ERROR / AndroidRuntime(4699):引起:java.lang.ClassNotFoundException:android.view.webView in loader dalvik.system.PathClassLoader@43457e60 “

有人知道发生了什么事吗? AlertDialog是否支持WebView?感谢您提前获得任何建议。

干杯, 克里斯

1 个答案:

答案 0 :(得分:8)

您需要编写 WebView ,而不是 webView 。大写 W

相关问题