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 swipable

Author: Ian Darwin
Published? true
FormatLanguage: WikiFormat

Problem:

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.

Solution:

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.

Discussion:

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

Download:

The source code for this project is in the Android Cookbook repository at http://github.com/IanDarwin/Android-Cookbook-Examples, in the subdirectory TabSwipeDemo.
No records found.