警报对话框未关闭 - "由于没有窗口焦点而取消事件"

时间:2016-01-26 11:46:35

标签: android dialog android-alertdialog

我有一个TYPE_SYSTEM_ALERT类型的警报对话框,带有2个按钮Ok&取消。 “确定”按钮打开一个新活动,其中“取消”按钮仅取消对话框。

警告它在另一个上面显示2次 - 如果按下取消按钮用于可见对话 - 它被解雇,第二个被解雇显示,一切正常。

我的问题是当从可见对话框中选择确定时 - 正在打开所需的活动,当前对话框正在被解除但是发生了奇怪的事情 - 活动显示在第一个对话框下方,当尝试选择其中一个时按钮显示消息错误cat blah/rsrc - 并且无法再访问该对话框。

我已经尝试过一个事件来请求关注剩余的警报 - 例如:

"Dropping event due to no window focus: MotionEvent"

 this.mAlertDialog.getWindow().getDecorView().setFocusable(true); 
 this.mAlertDialog.getWindow().getDecorView().setFocusableInTouchMode(true);
 this.mAlertDialog.getWindow().getDecorView().requestFocus();

但没有变化。

1 个答案:

答案 0 :(得分:1)

尝试其中一个

this.mAlertDialog.getWindow().getDecorView().setCancelable(true);

OR

this.mAlertDialog.setCancelable(true);

OR

...onclick(View v) {
this.mAlertDialog.cancel();
}

OR

...onclick(View v) {
this.mAlertDialog.dimiss();
}
相关问题