android - 当我单击“返回”按钮时,“警报”对话框和“进度”对话框关闭

标签 android android-alertdialog

在我的 android 应用程序中,我显示了警报对话框。当我单击 OnBack 按钮时,警告对话框被取消。我的问题是当用户单击该 onBack 按钮时。我必须显示该对话框。如何处理这个问题。提前致谢。

AlertDialog.Builder alertbox = new AlertDialog.Builder( HomeScreenActivity.this);
alertbox.setMessage("Please select a Favorite Business"); 
alertbox.setNeutralButton("Nearby", new DialogInterface.OnClickListener() 
   { 
    public void onClick(DialogInterface arg0, int arg1) { } }) 
    .setNegativeButton("Search",new DialogInterface.OnClickListener() 
       { public void onClick(DialogInterface dialog,int id) { } }); 
alertbox.show(); 

最佳答案

试试这个。它不会关闭对话框 onBackPress

alertbox.setCancelable (false) 

设置此对话框是否为Cancelable使用 BACK 键。

关于android - 当我单击“返回”按钮时,“警报”对话框和“进度”对话框关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15133877/

相关文章:

android - 在远程配置文本中添加换行符

android - 使用布局参数限制 AlertDialog 中 EditText 的宽度?

android - 使警报对话框在单击肯定按钮时不可关闭,直到条件为真

java - AlertDialog 上的 android-setAdapter 不工作

android - TextView 中的文本颜色改变颜色

android - 如何在 SQLite 中保存 pdf 文件

java - Android、SQL、空指针异常

android - 根据值(value)对 recyclerview 中的项目进行分组

android - listView 中的自定义 alertDialog

android - 带有包含复选框及其监听器的自定义适配器的警报对话框