我们能与后台活动在它的机器人显示一个对话框时,交互它的、能与、对话框、机器人

2023-09-12 22:16:53 作者:脑残儿童欢乐多°

我要显示在活动的对话,但仍希望与背景活动交互,以执行一些东西,在显示对话框时。如何才能做到这一点?

I want to display a dialog over an activity but still want to interact with background activity to perform something, while the dialog is being displayed. How can this be done?

推荐答案

使用 DialogFragment ,该是一个显示一个对话窗口,浮在其活动的窗口的顶部的片段。该片段包含一个对话的对象,它基于片段的状态显示为合适。对话框控制(决定何时显示,隐藏,关闭它)应通过API来完成这里,不与对话框上直接调用,所以你的活动仍然控制。

Use a DialogFragment, which is a fragment that displays a dialog window, floating on top of its activity's window. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog, so your Activity remains in control.