I\'m developing an app that has some tabs,something like this
Each tab is a Fragment
If what you want is replace a fragment inside the viewpager with another fragment, take a look at this. However I would suggest you to create another Fragment (a container), and move your viewpager and fragments inside of this new fragment:
This way when the user clicks an item of a list, you can replace the MainFragment
with a Details Fragment
.
About the ChildFragmentManager()
, it is used when you have nested fragments. If you change your implementation as I suggested, you would need to pass a ChildFragmentManager to your PagerAdapter:
viewPager.setAdapter(new AdapterView(getChildFragmentManager()));
Another thing about your commented lines of code inside VideosFragment
. Make your activity commit the fragment transaction instead of doing it inside the Fragment. For a better explanation, read this.