Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click?
What I wanted, after choosing multiple tabs one after another by
In the jetpack navigation, you have to make changes in only single navigation graph xml file for handle navigation, handle backstacks, custom animations, pass arguments between fragments.
If you want simply back to previous fragment,
btn_cancel.setOnClickListener {
it.findNavController().popBackStack()
}
If you want to clear all backstacks and go to new fragment
btn_submit.setOnClickListener {
it.findNavController().navigate(DeleteEmployeeFragmentDirections.actionDeleteEmployeeFragmentToEmployeesListFragment2())
}
For more reference: Jetpack Navigation Example