0
我搜索了很多並沒有找到解決方案。我使用電子郵件EditText
和兩個按鈕提交和取消,並根據我需要顯示不同的警報條件的警報對話框。但即時得到強制關閉錯誤和logcat
顯示:Android - Alert Dialog Force關閉錯誤
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)
,並在下面顯示在警報對話框警報對話框代碼:
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();
}
我搜索在Stackoverflow中也是如此。你可以幫我嗎,我需要改變代碼。請幫我解決這個問題。
你需要添加另一個對話框,你不能修改同一個對話框 –
該怎麼辦?請幫幫我@PankajKumar – user2381792
有這個AlertDialog.Builder alertForgotPassword = new AlertDialog.Builder(this);裏面的點擊方法,也許editext也 – Raghunandan