Skip to content Skip to sidebar Skip to footer

Swapping Viewpager With Single Fragment

I have an activity whose root layout is a drawer layout, with main content being a view pager (and com.astuetz.viewpager.extensions.PagerSlidingTabStrip to assist viewpager. Now wh

Solution 1:

The fragment overlaps the ViewPager because they are all in a RelativeLayout together - if you want to hide the ViewPager and the tab strip, you can call setVisibility(View.GONE) on each of them to hide them from view.

// assuming you do not already have a reference to them, // find them by their ID and hide themfindViewById(R.id.tabs).setVisibility(View.GONE);
findViewById(R.id.pager).setVisibility(View.GONE);

Edit: Actually, you could place the ViewPager and tab strip in a fragment of its own, and attach that to the fragmentToSwap FrameLayout so that your fragment transaction would actually do the replacement - depending on how your app is architected, that may make more sense.

Post a Comment for "Swapping Viewpager With Single Fragment"