[英]Android - Alert Dialog Force Close error
I have googled a lot and didnt find the solution. 我在Google上搜索了很多,却没有找到解决方案。 I am using alert dialog with Email
EditText
and two buttons Submit and Cancel and based on the conditions i need to show different alerts. 我使用带有电子邮件
EditText
和两个按钮Submit和Cancel的警报对话框,并根据情况需要显示不同的警报。 but im getting force close error and logcat
shows: 但即时通讯收到强制关闭错误,
logcat
显示:
05-16 13:16:48.281: E/AndroidRuntime(13572): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
05-16 13:16:48.281: E/AndroidRuntime(13572): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976)
05-16 13:16:48.281: E/AndroidRuntime(13572): at android.view.ViewGroup.addView(ViewGroup.java:1871)
05-16 13:16:48.281: E/AndroidRuntime(13572): at android.view.ViewGroup.addView(ViewGroup.java:1851)
and below is the code to display alert dialogs with in the alert dialogs: 下面是在警报对话框中显示警报对话框的代码:
forgotPasswordMailAlert() is : forgotPasswordMailAlert()是:
private void forgotPasswordMailAlert(String AlertText)
{
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(AlertText)
.setCancelable(true)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
I searched a lot in Stackoverflow as well. 我也在Stackoverflow中搜索了很多。 Can u please help me where i need to change the code.
您能在需要更改代码的地方帮我吗? Please help me how to resolve this issue.
请帮助我如何解决此问题。
Use alert.dismiss(); 使用alert.dismiss(); instead of dialog.dismiss();
而不是dialog.dismiss();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.