【问题标题】:How to avoid AlertDialogs overlapping each other?如何避免 AlertDialog 相互重叠?
【发布时间】:2018-01-20 14:47:02
【问题描述】:

我的应用中有一系列事件会导致显示多个AlertDialog,但它们会相互重叠,以便最新的事件位于顶部。

我怎样才能让AlertDialog 框等待轮到它们在用户关闭前一个框后才显示?

【问题讨论】:

  • 当用户点击是或否时,只显示另一个.....像这样继续......
  • 它们是由不同的逻辑触发的,所以一组组合可能会导致一些重叠

标签: android android-alertdialog


【解决方案1】:

有可能.. 如果您的各种事件响应流程已修复,那么您可以这样做

第一个警报对话框构建器:

.setPositiveButton("Yes", new DialogInterface.OnClickListener() {  
            public void onClick(DialogInterface dialog, int id) { 

            //whatever you want for positive response from user
            //open next alert dialg
            nextDialog();  

            }  
        })  
.setNegativeButton("No", new DialogInterface.OnClickListener() {  
            public void onClick(DialogInterface dialog, int id) {  
            //  Action for 'NO' Button  
            dialog.dismiss();  

            //whatever you want for positive response from user
            //open next alert dialg
            nextDialog(); 
         }  

在下一个警报对话框构建器中,您可以根据需要打开其他警报对话框。

如果您需要澄清,请发表评论。

编码愉快...

【讨论】:

  • 不,流量不固定。有不同的事件可以触发对话框,有时它们会重叠。
  • 感谢您的回答,但 OP 应指出这一点以澄清问题。我也有同样的问题
猜你喜欢
  • 2012-05-09
  • 2020-10-11
  • 2023-04-06
  • 1970-01-01
  • 1970-01-01
  • 2018-02-12
  • 2017-03-27
  • 2018-01-20
  • 1970-01-01
相关资源
最近更新 更多