带有片段的ViewPager和FragmentPagerAdapter(不支持库) [英] ViewPager and FragmentPagerAdapter with Fragments (not support library)
问题描述
我想在视图分页器中使用片段(不支持片段),我知道v13库支持片段,但是我不想为我的项目导入整个库.
I would like to use fragments (not support fragments) with a view pager, I understand the v13 library has support for fragments but I don't want to import the whole library for my project.
有人知道如何找到解决方法吗?例如带有片段的FragmentPagerAdapter的实现.
Does anyone know how to find a way round this? e.g an implementation of the FragmentPagerAdapter with Fragments.
谢谢
推荐答案
ViewPager
是Java类.可以在android-support-v4
和android-support-v13
库中找到. android-support-v13
是android-support-v4
的超集,添加了一些仅当android:minSdkVersion
为13或更高时才相关的类,例如FragmentPagerAdapter
的本机片段版本.
ViewPager
is a Java class. It can be found in the android-support-v4
and android-support-v13
libraries. android-support-v13
is a superset of android-support-v4
, adding in some classes that are only relevant if your android:minSdkVersion
is 13 or higher, such as the native fragment version of FragmentPagerAdapter
.
我的猜测是,您认为同时需要android-support-v4
和android-support-v13
,这是不正确的-您只需要android-support-v13
.
My guess is that you think that you need both android-support-v4
and android-support-v13
, which is incorrect -- you only need android-support-v13
.
当然,欢迎您发布自己的恰巧使用本机片段的PagerAdapter
实现.
You are, of course, welcome to roll your own PagerAdapter
implementation that happens to use native fragments.
这篇关于带有片段的ViewPager和FragmentPagerAdapter(不支持库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!