【问题标题】:How to make callBack response from one fragment to another fragment?如何从一个片段到另一个片段的回调响应?
【发布时间】:2020-01-23 12:34:40
【问题描述】:

先生/女士, 我想使用 android JAVA 将一个片段的回调结果发送到另一个片段。 我尝试找出问题,但没有找到解决方案。 如果我使用接口,它会向 Activity 发送回调响应,这是我不想要的。 谢谢!

【问题讨论】:

标签: android


【解决方案1】:

您有很多选择:

  1. 共享视图模型(推荐)(https://medium.com/@abhilashmyworld/communicate-between-fragments-using-viewmodel-e83344e9df53)

  2. 事件总线

  3. 通过 Hosting 活动(在片段对象上调用方法)

  4. 传递对象

  5. 广播(太老派)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-25
    • 2016-09-30
    • 1970-01-01
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    相关资源
    最近更新 更多