简体   繁体   English

Android / Fragment-如何传递Last Fragment的参数并发送给Previous Fragment?

[英]Android / Fragment - How do I pass parameters of the Last Fragment and send to Previous Fragment?

  • I have the following situation: I open the Fragment A and goals, through a click event of the button, go to the Fragment B. When I am in Fragment B and hit the back button (in order to return to the Fragment A) I would like to pass some parameters to Fragment A. Does anyone know how I can do this? 我遇到以下情况:打开片段A,并通过按钮的click事件进入目标,转到片段B。当我在片段B中时,单击“后退”按钮(以便返回到片段A),我想将一些参数传递给片段A。有人知道我该怎么做吗?
  • Thank you in advance to all. 预先谢谢大家。

您的活动可以在“活动”上实现自定义侦听器接口,并在片段中使用对该接口的引用来将通信传递回去。

You can send a broadcast when you hit the back button in Fragment B to Fragment A with the parameters you need put in the bundle, and have broadcast receiver on the Fragment A. 当您按片段B中的后退按钮向片段A发送广播时,您需要使用捆绑中需要的参数,并在片段A上具有广播接收器。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM