New navigation component from arch with nested navigation graph

后端 未结 7 1157
栀梦
栀梦 2020-12-07 11:26

I have one case and wish to implement it by arch navigation component. For example I have 2 Nav Graphs (main and nested). Can I call main graph from nested and how?

7条回答
  •  离开以前
    2020-12-07 11:57

    Actually you could use Global actions to navigate from a nested nav graph destination to a main nav graph destination.

    Create a global action from nested nav graph to desired destination in main nav graph (highlighted in the image below)

    example:

    
         
         
         
    
         
               ...
    
         
         
         
    
    
    

    To navigate to main graph destination use

    findNavController().navigate(R.id.action_global_start)
    

提交回复
热议问题