3

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

ただし、「View alertDialogView = inflater.inflate(R.layout.dialog_layout、null);」でエラーが発生しました。「android.view.InflateException:バイナリXMLファイルの行#6:クラスwebViewのインフレーションエラー」および「11-2617:15:47.934:ERROR / AndroidRuntime(4699):原因:java.lang.ClassNotFoundException:android.viewローダー内の.webViewdalvik.system.PathClassLoader@43457e60 "

何が起こったのか誰か知っていますか?AlertDialogはWebViewをサポートしていますか?よろしくお願いします。

乾杯、クリス

4

1 に答える 1

8

webViewではなくWebViewを作成する必要があります。大文字W

于 2010-11-26T07:00:24.960 に答える