4

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.

Does anyone know how to find a way round this? e.g an implementation of the FragmentPagerAdapter with Fragments.

Thanks

AndroidEnthusiast
  • 6,557
  • 10
  • 42
  • 56

1 Answers1

15

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.

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.

You are, of course, welcome to roll your own PagerAdapter implementation that happens to use native fragments.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 2
    Thanks a lot! I still don't understand why we have to use support libraries for basic features like the ViewPager. Is there a "native" solution for newer Android versions, that I was not able to find? – Andras Balázs Lajtha Sep 27 '14 at 10:08
  • 1
    @AndrasBalázsLajtha: No, `ViewPager` is not part of the framework in any Android release. The same holds true for `DrawerLayout`/`ActionBarDrawerToggle`, `SlidingPaneLayout`, etc. – CommonsWare Sep 27 '14 at 10:38
  • if you want to use ViewPager and FragmentPagerAdapter in android:minSdkVersion >=13 you must use android-support-v13, else use just android-support-v4, but don't use them together – Stoycho Andreev Apr 10 '15 at 17:09