我想这是一个愚蠢的问题,但我是Android的新手,我仍然无法理解片段之间的通信。我想做的事:
我有一个DialogFragmentA
包含一些方法和DialogFragmentB
包含yesButton
和noButton
。
如果点击了yesButton
中的DialogFragmentB
,我想解散该片段并在DialogFragmentA
中触发一个特定的动作。
怎么能实现呢?
如果两个片段都是对话框,则可以执行以下操作:将dialogFragmentA设置为dialogFragmentB的targetFragment在dialogFragmentB中,使用getTargetFragment获取dialogFragmentA。然后使用该引用调用dialogFragmentA中的任何方法
在对话框中使用ViewPager