我在单独的文件中创建了多个图表。
第一个是图A 它包括图B . startDestination
的 图B 是 fragment B 有一个名为 的参数AnID
现在我想通过 AnID 来自 图A 至图B ( fragment B )
尽管编辑器知道该参数,但生成的代码不考虑该参数:
val directionB = FragmentADirections.actionFragmentAToGraphB(/* HAS NOT ARGUMENT */)
findNavController().navigate(directionB)
如何将参数传递给嵌套图?
最佳答案
我发现了这个,但这不是官方的解决方案:
val direction = FragmentADirections.actionFragmentAToGraphB()
findNavController().navigate(direction.actionId, FragmentBArgs(anId).toBundle())
更新:有人介绍another way通过在行动中定义嵌套图参数
关于android - 将参数传递给嵌套图 startDestination,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60016118/