Using a PagerSlidingTabStrip with a Viewpager inside of a fragment:
Any ideas?
This method may be called by the ViewPager to obtain a title string to describe the specified page. This method is deprecated. This method should be called by the application if the data backing this adapter has changed and associated views should update.
ViewPager save Fragment in FragmentManager with particular tags, So We can get ViewPager's fragment by FragmentManager class by providing tag. And ViewPager provide tag to each fragment by following syntax : Fragment page = getSupportFragmentManager(). findFragmentByTag("android:switcher:" + R.
To use ViewPager and tabs, you need to add a dependency on ViewPager and on Material Components to your project. To insert child views that represent each page, you need to hook this layout to a PagerAdapter .
So a Viewpager is an android widget that is used to navigate from one page to another page by swiping left or right using the same activity. So when we use Viewpager, we can add different layouts in one activity and this can be done by using the fragments.
I had a problem like that
try this
mPager.setAdapter(new BasePagerAdapter(getChildFragmentManager(), getResources()));
you probably have this
mPager.setAdapter(new BasePagerAdapter(getFragmentManager(), getResources()));
EDIT: and in your BasePagerAdapter extend FragmentStatePagerAdapter
public class BasePagerAdapter extends FragmentStatePagerAdapter {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With