如何prevent警告对话框过得去后退按钮关闭 [英] How to Prevent an Alert Dialog Getting Closed by Back Button
本文介绍了如何prevent警告对话框过得去后退按钮关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的警告对话框:
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?
推荐答案
使用<一个href="http://developer.android.com/reference/android/app/Dialog.html#setCancelable%28boolean%29">Dialog.setCancelable():
设定这个对话框是否取消与返回键。
Sets whether this dialog is cancelable with the BACK key.
在你的code这将是:
In your code this would be:
oyunaBaslaDialog.setCancelable(false);
这篇关于如何prevent警告对话框过得去后退按钮关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文