【发布时间】:2013-04-25 06:17:40
【问题描述】:
我的应用程序有一个 webview,当用户没有输入正确的用户名和密码时,会弹出一个警告对话框并告诉他。
我的 Webview 接口类是:
public class WebAppInterface extends FragmentActivity{
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String text) {
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}
public void showErrorDialog(String text) {
DialogFragment dialogFragment = new ErrorDialog();
dialogFragment.show(getSupportFragmentManager(), "errorDialog");
}
}
而我的 Dialgofragmenct 类是:
public class ErrorDialog extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("שגיאה");
builder.setMessage("טקסט כלשהו");
builder.setPositiveButton("אישור", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
builder.setCancelable(false);
return builder.create();
}
}
当我在eclipse上运行调试器时,界面中的方法showErrorDialog()有效,但是当方法结束时应用程序curshes,并且根本不显示警告对话框!!!
请帮忙!
【问题讨论】:
标签: android android-fragments android-webview android-dialog android-dialogfragment