【问题标题】:Android - callback if DialogFragment is closes in another DialogFragmentAndroid - 如果 DialogFragment 在另一个 DialogFragment 中关闭,则回调
【发布时间】:2016-10-04 13:08:50
【问题描述】:

有一个 DialogFragment DialogA,在此之上还有另一个 DialogFragment DialogB。如果DialogB 关闭,则应该在DialogA 上触发一个事件,以便可以刷新视图(无论是否按下“YES”、“CANCEL”或返回)。

如何获得DialogB的闭幕事件?

我尝试使用 BroadcastReceiver 并覆盖 onResume。但是如果 DialogB 关闭,它们都不会被解雇。

知道如何实现吗?

【问题讨论】:

  • 你尝试过使用setOnDismissListener 进行对话吗?
  • 检查事件总线它将帮助您接收事件。 greenrobot.org/eventbus

标签: android dialogfragment


【解决方案1】:

您为什么不在对话框 A 中创建一个公共方法,然后单击“是”或“否”按钮,无论它是什么,调用该方法并关闭对话框 B。

【讨论】:

  • 我无法访问 DialogB 中的 DialogA。它们是独立的类而不是嵌套的。
  • 如果是独立类,可以在B中创建A的对象,然后使用该对象调用该方法。
猜你喜欢
  • 1970-01-01
  • 2014-07-31
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 2013-07-01
  • 2020-11-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多