如何使用 Android 导航将数据传递到前一个片段?
我的应用程序以 NewAdFragment
开头,在这个片段中,有一个按钮允许用户选择类别,当用户单击该按钮时,我将把他导航到 ChooserFragment
通过传递类别列表作为参数,此片段内有 RecyclerView,它显示类别。
我想要什么?我希望当用户从RecyclerView中选择一个项目时,它必须返回到具有特定数据的NewAdFragment
。
我可以用很多方法解决这个问题,但也许导航组件库中已经存在一种方法。
最好的方法是什么?
My app starts with NewAdFragment
and inside this fragment, There is a button that allows user to choose the category, When the user clicks on the button I'll navigate him to ChooserFragment
with passing categories list as an argument, There is RecyclerView inside this fragment and it shows categories.
What do I want? I want when the user chooses an item from RecyclerView, Then it must back to NewAdFragment
with specific data.
I can solve this problem in a lot of ways but maybe there is a method that exists in the navigation component library already.
What is the best way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试实现此处提到的以下代码块:
FRAGMENT A
FRAGMENT B
您还可以检查这个
try to implement below code blocks as mentioned here:
FRAGMENT A
FRAGMENT B
you can also check this