Search code examples
javaandroidandroid-fragmentsandroid-viewpager

Android ViewPager Fragments - No Swipe and Preloading?


I have a pretty standard implementation of ViewPager using Fragments; however I'm wondering if it's possible to get rid of the preloading of tabs, and to only load a tab activity once user clicks on it?

Also, can we get rid of the swipe effect, just like in iOS?

Thank you


Solution

  • If you want the user to only click on tabs, then don't use a ViewPager; put the views in a FrameLayout, make them all invisible and only set the view that is selected visible. When the user clicks on a tab, make the current view invisible and selected view visible. Much simpler than implementing a PagerAdapter.