I have a recyclerView inside a fragment, and when I click an item I want to navigate to next fragment. At the first time I click, it's OK, but after getting back to this fragment and clicking the same item again my application crashes. Could anyone please tell me how to call navigation.navigate inside recyclerView item?
Asked
Active
Viewed 83 times
1 Answers
0
If you are using the navigation compenent, and inside the recyclerview, you need to go to another class, use the following:
Navigation.findNavController(itemView).navigate(
UIFragmentVideoListDirections.aVideoList2Video((aFile.absolutePath))
)
Please try and let me know.
Added Answer:
NavHostFragment — implementation of NavHost for creating fragment destinations. It has its own NavController and navigation graph. Typically you would have one NavHostFragment per activity.
Navigation — helper class for obtaining NavController instance and for connecting navigation to UI events like a button click.
NavigationUI — class for connecting app navigation patterns like drawer, bottom navigation or actionbar with NavController.

Miriana Itani
- 865
- 9
- 25
-
1Thank you so much for guidance; I found the problem, I have called "popBackStack()" instead of "navigateUp()" in the next fragment. So when getting back to the first fragment, there was no destination to In case of clicking the same item of recyclerView! – Ehsan Haghdoust Nov 11 '19 at 20:41