androidkotlinandroid-architecture-navigationfragmentmanagerandroid-safe-args

Navigation action/destination /action_creditTabFragment_to_needHelpFragment cannot be found from the current destination Destination(creditFragment)


My app uses navigation component, I have CreditFragment and it uses TabLayout with ViewPager2, it contains CreditTabFragment, when I am at the CreditTabFragment I want to navigate to NeedHelpFragment using findNavController().

How can I make the Navigation Controller know I'm on creditTabFragment?

I tried to create a childFragmentManager but without success

ClickListener of the button that navigates to NeedHelpFragment

Sweta Jain showed this error, I couldn't add Navigation.findNavController().navigate(action) from the Answer


Solution

  • I Used child fragment manager where i set my view pager adapter: viewPager.adapter = SectionsPageAdapter(childFragmentManager, lifecycle) With this you will be able to use navigation, note: the navigations must be in the father fragment, not in the tabs layouts.