AlertDialog是否支持WebView?
问题描述:
我想用Webview里面实现AlertDialog。AlertDialog是否支持WebView?
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:错误/ AndroidRuntime(4699):导致:java.lang.ClassNotFoundException:android。在装载机中查看.webView [email protected] “
有谁知道发生了什么? AlertDialog是否支持WebView?提前感谢您的任何建议。
干杯, 克里斯
myWebView在“WebView myWebView =(WebView)findViewById(R.id.DialogWebView);”时总是为空。我仍然需要帮助~~谢谢 – ThinkChris 2010-11-29 04:17:53