I use navigation library and safeargs for passing data. I define argument to fragment like that.
Also make sure to use an up to date version. Had the problem, that I had an 1.X version.
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.2.1"
implementation "androidx.navigation:navigation-ui-ktx:2.2.1"
And the args correctely in the nav.xml:
Code:
override fun onItemClicked(category: Category) {
val action = CategoryFragmentDirections.actionCategoryToProductFragment(products = "myString") // /!\
view?.findNavController()?.navigate(action)
}