在没有支持库的情况下使用 FragmentStatePagerAdapter
我想知道是否可以在没有支持库的情况下使用 FragmentStatePagerAdapter 类或其等效类?
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 {...
推荐答案
我想你已经阅读了 ViewPager
docs,但以防万一:
I presume you've read the ViewPager
docs, but just in case:
该课程目前处于早期设计和开发阶段.这API 可能会在以后的兼容性库更新中发生变化,编译时需要更改应用程序的源代码针对较新的版本.
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.
我最初也对为什么 PagerAdapter 类不是 android.app.*
命名空间的一部分感到困惑.由于它们仍在改进中,因此它们已包含在支持库中,以便这些库可以在引入更改时频繁更新(AOSP 更新不那么方便,因此发生的频率要低得多).看来,一旦 Android 团队最终确定了 ViewPager
及其所有相关类,它们将成为 AOSP 的一部分.甚至 ViewPager
类本身仍然是 V4 支持库的一部分.所以你想要的应该在不久的将来成为可能...... :)
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 ... :)
相关文章