我有一个这样的警告对话框:
I have an alert dialog like this:
AlertDialog.Builder oyunaBaslaDialog = new AlertDialog.Builder(this);
oyunaBaslaDialog.setMessage("A Takımı");
oyunaBaslaDialog.setNeutralButton("Başla!",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
oyunOyna();
}
});
oyunaBaslaDialog.show();
显示在onCreate方法此对话框。我希望它只是通过它的按钮来关闭。但硬件后退按钮也可以关闭此对话框而不进行对话的行动。
This dialog is shown in onCreate method. And I want it just to be closed by the button on it. But Hardware Back Button can also close this dialog without dialog's action performed.
我不想后退按钮关闭对话框,我能做些什么?
I dont want the back button close this dialog, what can i do?
使用Dialog.setCancelable():
设定这个对话框是否取消与返回键。
Sets whether this dialog is cancelable with the BACK key.
在你的code这将是:
In your code this would be:
oyunaBaslaDialog.setCancelable(false);
下一篇:自动添加行为的体现?行为