[英]popUpTo nested navigation graph ID not popping to startDestination
[英]Pass argment to a nested graph's startDestination
我在單獨的文件中創建了多個圖形。
第一個是GraphA ,它包括GraphB 。 startDestination
的startDestination是FragmentB ,它有一個名為AnID的參數
現在我想將AnID從GraphA 傳遞到GraphB ( FragmentB )
盡管編輯器知道該參數,但生成的代碼不考慮該參數:
val directionB = FragmentADirections.actionFragmentAToGraphB(/* HAS NOT ARGUMENT */)
findNavController().navigate(directionB)
如何將參數傳遞給嵌套圖?
我找到了這個,但這不是官方解決方案:
val direction = FragmentADirections.actionFragmentAToGraphB()
findNavController().navigate(direction.actionId, FragmentBArgs(anId).toBundle())
更新:
有人通過在操作中定義嵌套圖參數引入了另一種方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.