'findNavController() not working for bottomNavigationBar
I have a bottom navigation bar as an activity, in which i have three fragments, i.e. HomeFragment, GameFragment, WalletFragment.
The bottom navigation bar is working fine and i am able to move between the three fragments.
From the HomeFragment on the press of a specific button, i want to navigate to a different fragment which is not a part of navigation bar. For this purpose, i am using findNavController().navigate(action)
But as soon i am tapping on the button, my app crashes and i am thrown to the very first framgment of my app.
Below is the full code that i am using to navigate:
binding.getStarted.setOnClickListener {
val action = HomeFragmentDirections.actionLandingFragment ()
findNavController().navigate(action)
}
The Runtime Error i am getting is:
androidx.constraintlayout.widget.constraintlayout does not have a navController set
Ps: I've tried to do this with explicit intent, but the app is still crashing on the press of that button
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
