【发布时间】:2023-03-27 04:31:01
【问题描述】:
我显示一个带有关闭按钮的对话框和一个打开新对话框的按钮。除非我在当前对话框的顶部打开了第二个对话框,否则关闭按钮可以正常工作。我认为我的对话框失去焦点,无法关闭。
public void anotherOne(View v){
openDialog2(); //This opens another dialog on top of the current one
}
public void closeDialog(View v){
dialog.cancel(); //This works fine unless anotherOne() has been called and closed
}
即使在打开和关闭当前对话框之上的另一个对话框之后,如何将焦点重新附加到当前对话框?
【问题讨论】:
-
贴出相关代码。您的代码不足以理解确切的问题。
-
代替 dialog.cancel() 尝试 dialog.dismiss();
标签: java android xml algorithm dialog