Archive for July, 2012
Slide Tabs With ViewPager
In my previous two posts, I explained how you would implement Tabs using Fragments and then how to implement page swiping using ViewPager. In this post, I’ll bring those two nuggets together and show you how to implement Swipe-able Tabs (i.e switch between tabs using the swipe gesture).
* Caveat Alert * At the time of this posting, there is no way of implementing MapView as a fragment, which may put a spanner in the works if you’re thinking about using this UI pattern with a MapView.
To implement a Tabs & ViewPager, using fragments on devices running Android 2.1 or higher, you’ll need to include the Android Compatibility library. In my example, I’m using Compatibility library v4.
- Define the Tab ViewPager layout
- Define the PagerAdapter
- Define the Tab FragmentActivity
The Tab ViewPager layout
The Tab ViewPager layout (tabs_viewpager_layout.xml) declares a TabHost and child TabWidget
View original post 275 more words