Search code examples
androidandroid-viewpagerfragmentandroid-support-librarynative-methods

How can I implement horizontal swipe not using the support library?


If I do not need to grant support for older versions of android and can just use API 17, is there an alternative way to implement the much advertised horizontal swipe (like in gmail) and not use viewpager, fragmentsactivities (new APIs already have fragments...) etc. to get rid of the support library?

All the tutorials I've found for horizontal swipe show how to do it using the support library and FragmentActivities. Otherwise what is the advantage of the new APIs if I cannot use their native classes and methods?


Solution

  • to get rid of the support library

    ViewPager only exists in the Android Support Library. The Android Support Library is not just for backports.

    new APIs already have fragments

    ViewPager can use native API Level 11 fragments, though you may need to create your own PagerAdapter. Or, you can use ViewPager without any fragments, using just ordinary View or ViewGroup objects for the pages.

    is there an alternative way to implement the much advertised horizontal swipe

    You are welcome to write your own replacement for ViewPager. Most developers prefer to reuse ViewPager, for reduced development and maintenance costs.

    There is also HorizontalScrollView, an open source HorizontalListView floating around, and so on.