I have 3 fragments in my tab layout . When I select 2nd fragment in my tab layout in that second fragment I'm clicking view all for the second fragment.. After enter into 2nd fragment view all , I'm clicking back button. At the time in my tab layout it goes to 1st fragment not stayed in the second fragment. I need to stay in the selected fragment.. Please help me how to do this.
private const val NUM_TABS = 3
class ViewPageAdapter (fragmentManager: FragmentManager, lifecycle: Lifecycle) :
FragmentStateAdapter(fragmentManager, lifecycle) {
override fun getItemCount(): Int {
return NUM_TABS
}
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> {
TodayFragment()
}
1 -> {
UpcomingFragment()
}
else -> {
PastFragment()
}
}
}
}