我想用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