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?
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.
You can write your own FragmentPagerAdapter
which works with android.app.Fragment
instead of android.support.v4.app.Fragment
to minimize dependency on the support library. You only need to create your own class for the adapter (based on FragmentPagerAdapter
from support library which source can be found in folder <android-sdks>/extras/android/support/v4/src/java/android/support/v4/app/
). Only modification is in the import section - you should reference Fragment
, FragmentManager
and FragmentTransaction
from android.app
instead of android.support.v4.app
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With