Viewpager2 is not loading fragment on clicking tab ,but works on swiping
I am using ViewPager2 with Tablayout . Initially everything works fine. ie, both swipe and clicking on Tab ,loads the correct fragment. Say I have 3 fragments Tab A, Tab B and Tab C. I need to open other fragments from Tab B ,say Tab B1.Tab B1 is opened and on pressing back button it goes back to Tab B. Now when I click on Tab A, it higlights TabA, but the fragment for Tab A is not loaded. But if we swipe, its working properly . Below is my Viewpager code.