0
I’m having a problem with an app I’m designing. I have 3 Fragments ( F1, F2, and F3):
- In F1 (contains a list with a series of sports) the user makes the choice regarding a sport (I use a Recycleview for this).
- In F2 (contains a list with a series of spaces) the use choose the space ( I also use a Recycleview)
The point is that in F3 I want to "summarize" the user’s choices( Selected sport, selected space).
My question is what is the most efficient way to pass these arguments between the 3 Fragments?! Sharedviewmodel or used Safeargs?! I tried to use Sharedviewmodel but in F3 the variable will always null.
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.itemview.text=listsports[position]
holder.itemview.setOnClickListener{
val sViewModel=SharedViewModel()
sViewModel.setSport(adapterposition)
v:View->v.findNavcontroller().navigate(R.id.action_F1_to_F2)}
}
}