I am trying to load the contents of recyclerView on a new screen I navigate to using navigation components.. I think with activity it was intentPutExtra, or something like this.
I'd appreciate if you could write a sample code, but I don't mind any pointers, thanks in advance. I'm new, and I don't really to the informartion to provide, so please if you need anything I am more than happy to provide, thanks in advance.
Here's the code from the recyclerView Adapter, that navigate into the fragment:
// binds the list items to a view
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
...
// navigates to stories content destination
holder.storiesCardView.setOnClickListener {
val action = StoriesFragmentDirections.actionNavigationStoriesToStoriesContentFragment()
holder.itemView.findNavController().navigate(action)
}
}
So I'm using safeArgs(ver 2.3.1) FragmentDirections to navigate.
Please if you decide to show a sample code, I intend to use predefined text in string.xml file.
I'd love to add more info but I want this to be short as possible. So please if you want any info let me know.. Thanks again..
At ur navgraph
at navigating place
Note:CustomModel should be Parcelable or Serializable.
at retriving in fragment like below