Home » Android » java – Using FragmentStatePagerAdapter WITHOUT support library

java – Using FragmentStatePagerAdapter WITHOUT support library

Posted by: admin April 23, 2020 Leave a comment

Questions:

I would like to know is it possible to use the class FragmentStatePagerAdapter or its equivalent without the support library?

I know how to use native fragments in place of those from the support library and many other classes have their similar equivalents, but I can’t find what should be used instead of this class.

I basically want to extend it for using it in my adapter like this

public class ImageAdapter extends FragmentStatePagerAdapter {...
How to&Answers:

I presume you’ve read the ViewPager docs, but just in case:

This class is currently under early design and development. The
API will likely change in later updates of the compatibility library,
requiring changes to the source code of apps when they are compiled
against the newer version.

I too was initially baffled as to why the PagerAdapter classes were not a part of the android.app.* namespace. As they are still undergoing refinement, they have been included in the support libraries so that those libraries can be updated frequently as changes are introduced (AOSP updates are far less convenient and thus occur on a far less frequent basis). It seems that once the Android team gives final shape to the ViewPager and all its related classes, they will become a part of the AOSP. Even the ViewPager class itself is still a part of the V4 support library. So what you want should be possible in the near future … 🙂