Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Creating a Tabbed Activity that is tappable and swipableBack to Android Cookbook Home | Up to Chapter: Graphical User Interface

Author: Ian Darwin ('idarwin')
In Published Edition? Yes
FormatLanguage: WikiFormat

Creating a Tabbed Activity that is tappable and swipable


Your UI is too complex to fit comfortably in a single Activity, but you don't want to break it down into multiple discrete Activities. And you want the user to have the flexibility to either tap on Tabs or to swipe left/right to navigate between sections.


Use a ViewPager as your main Activity view, and an ActionBar with its Navitation Mode set to Tabs; add some tabs to the ViewPager, add an adapter and listener or two, and you're ready to go.


This will take some explaining. But the code's there if you want to look!

See Also


The source code for this project is in the Android Cookbook repository, http://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/TabSwipeDemo