在另一个对话框上方显示Android对话框? [英] Display Android dialog on top of another?

查看:60
本文介绍了在另一个对话框上方显示Android对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个警报对话框,分别是对话框A和对话框B.单击对话框A的按钮之一将弹出对话框B.然后,我想要一个按钮将关闭对话框B并返回到对话框A.除了对话框B执行showDialog(dialogA)之外,还有其他方法吗?

I have 2 alert dialogs, dialog A and dialog B. Clicking on one of dialog A's buttons will bring up dialog B. I then want to have a button that will dismiss dialog B and return to dialog A. Is there a way to do this apart from dialog B performing a showDialog(dialogA) ?

这可行,但是您可以看到对话框A的重新加载,而不仅仅是返回到已经存在的对话框A.在对话框B中执行关闭操作只会关闭这两个对话框.

This works, but you can see the reload of dialog A, instead of just returning to an already existing dialog A. Performing a dismiss in dialog B just dismisses both of them.

一个小问题,但我想看看是否有一种方法可以将它们堆叠在一起.

A minor question, but I'd like to see if there is a way to stack them on top of one another.

谢谢

推荐答案

使用基本对话框构建块无法将它们堆叠在一起,您将需要重新显示第一个对话框.这样做的原因是,当您按下对话框按钮时,它将在内部关闭该对话框,这是调用在对话框构建器API中为每个按钮分配的单击处理程序的过程的一部分.

Using the basic dialog building blocks it is not possible to have them stack, you will need to re-show the first dialog. The reason for this is that when you press a dialog button it internally will dismiss the dialog as part of the process for calling the click handler you assigned for each button in the dialog builder API.

解决此问题的一种方法是,通过在布局中设置自己的按钮,而不是使用由对话框构建器方法创建的按钮,来制作不具有关闭行为的自定义对话框布局.然后,在您自己的按钮的单击处理程序中,仅显示第二个对话框而不忽略第一个对话框. http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

One way around this is to make a custom dialog layout that doesn't have the dismiss behavior, by setting up your own buttons in the layout, rather than using those created by the dialog builder methods. Then in the click handler for you own buttons simply show the second dialog without dismissing the first. http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

这篇关于在另一个对话框上方显示Android对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆