I am using Jetpack navigation to navigate between the fragments.Since I am using it for the first time I am unaware about how it will navigate from fragment two to fragment one on click of a button or based on some condition in the application.Please let me know if anyone knows about it
Asked
Active
Viewed 54 times
1 Answers
0
Try these codes:
yourButton.setOnClickListener(){
activity?.onNavigateUp()
}
or
val activity = requireActivity()
yourButton.setOnClickListener(){
if (activity is YourMainActivity) {
activity.onSupportNavigateUp()
//or
activity.onBackPressed()
}
}

TinaTT2
- 366
- 5
- 17