Lets say I have a fragment flow defined by my nav graph using the Navigation Components and the safe-args plugin. How do I pass arguments to my nav host fragment?
Asked
Active
Viewed 268 times
0
-
In your nav host fragment you have a startDestination, is your question basically more how do you pass arguments to your startDestination fragment from other destination fragments? – Lucho May 17 '20 at 19:00
1 Answers
0
what for you need to pass to nav host fragment? you can use shared ViewModel to pass some data from one fragment to another. for example if you need to share some data between fragments that are in the same navigation graph you can use trap scope ViewModel otherwise activity scope ViewModel.
activity scope (val viewModel: YourViewModel by activityViewModels()
)
or
navigation graph scope (val viewModel: YourViewModel by navGraphViewModels(R.id.desired_graph)
)

Davit Dolmazyan
- 76
- 1
- 4
-
Thanks, I did not know about the navGraphViewModels(). But this does not really answer my main question, how to fill the defined arguments for a nav host fragment. – Palm May 05 '20 at 06:33