我正在尝试实现一个带有 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" />
但是,我在“ViewalertDialogView = inflater.inflate(R.layout.dialog_layout, null);”处收到错误说“android.view.InflateException:二进制 XML 文件第 6 行:错误膨胀类 webView
”和“11-26 17:15:47.934:错误/AndroidRuntime(4699):引起:java.lang.ClassNotFoundException:加载程序dalvik.system.PathClassLoader@43457e60中的android.view.webView
”
谁能知道发生了什么事吗? AlertDialog 支持 WebView 吗?感谢您提前提供任何建议。
干杯,
克里斯
你需要写WebView, not webView。大写W
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)