Does the Android ICS API have a native equivalent to ViewPager support lib?

eephyne picture eephyne · Mar 31, 2012 · Viewed 7.4k times · Source

I have searched a bit around for a pager for fragment , I develop on ICS API.

I know about ViewPager and all the support libs for earlier version but i don't get why I should use a support library consider the fact that I use the lastest version of the api and don't plan to support earlier version.

Do I have to write the "ViewPager" myself or is there something i didn't see in the api.

Answer

CommonsWare picture CommonsWare · Mar 31, 2012

Does the Android ICS API have a native equivalent to ViewPager support lib?

No.

I know about ViewPager and all the support libs for earlier version but i don't get why I should use a support library consider the fact that I use the lastest version of the api and don't plan to support earlier version.

The Android Support package is not only for backports of newer APIs. It is also for other classes that, for whatever reason, are not being added to the SDK, such as ViewPager and its supporting classes.

Do I have to write the "ViewPager" myself or is there something i didn't see in the api.

You are welcome to write your own implementation of a view paging component. Savvy programmers would use the one in the Android Support package, since it is already written and (mostly) debugged.

UPDATE: Note that ViewPager works just fine with pages that are:

  • API Level 11+ native fragments
  • Android Support backported fragments
  • arbitrary Views

For the first case, you need the v13 version of the support JAR, which contains v13 versions of the FragmentPagerAdapter and FragmentStatePagerAdapter classes.