使用FragmentStatePagerAdapter无支持库 [英] Using FragmentStatePagerAdapter WITHOUT support library

查看:132
本文介绍了使用FragmentStatePagerAdapter无支持库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能使用类FragmentStatePagerAdapter或其等价物,而不支持库?

我知道如何使用原生片段代替那些支持库和许多其他类有其相似的等价物,但我找不到应该用什么来代替这个类。

我基本上是想扩展它在我的适配器像这样使用它

 公共类ImageAdapter扩展FragmentStatePagerAdapter {...
 

解决方案

我presume您已经阅读 ViewPager 文档,但以防万一:

  

这个类是目前在早期的设计和开发。该   API将在兼容性库的后续更新可能会改变,   无需更改应用程序的源$ C ​​$ C被编译时,   对较新的版本。

我太最初感到困惑,为什么PagerAdapter类是不是 android.app的一部分。* 命名空间。由于它们仍在进行细化,他们已被列入支持库,使这些库可以经常更新的变化进行了介绍(AOSP更新是远远不太方便,因此发生在远那么频繁)。看来,一旦Android团队给出最终形状的 ViewPager 及其所有相关类,它们将成为AOSP的一部分。即使是 ViewPager 类本身仍然是V4支持库的一部分。所以,你想要的东西应该有可能在不久的将来...:)

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 {...

解决方案

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 ... :)

这篇关于使用FragmentStatePagerAdapter无支持库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆