Reputation: 9994
My plan is creating an Activity includes Tabs+Swipe for all Android version. If we set it from a default Android project, it has just support for at least API 11.
In Sherlock we have two project named : Tab Navigation, Tab Navigation(collapsed) includes Tabs but not Swipe. They have Issue #240 in their samples that has a bug (swipe left/right when the tabs are in collapsed mode (landscape) and the selected item does not update).
Do you know any sample code that solve this problem?
Upvotes: 7
Views: 13608
Reputation: 2804
I also happened to have same situation. Follow below links and you will get all what you need.
See this tutorial http://droidista.blogspot.com/2012/08/making-actionbarsherlock-and.html
And get demo code from here https://github.com/zmdominguez/vpi-abs-demo
Upvotes: 5
Reputation: 12269
I found these links which might help you out.
Upvotes: 2
Reputation: 5161
You made this now with the default Android Support Library (or the ABS), with a ViewPager
and a PagerTabStrip
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.PagerTabStrip
android:id="@+id/tabStrip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</android.support.v4.view.ViewPager>
</LinearLayout>
Then create an Adapter
to the ViewPager
that extends of FragmentStatePagerAdapter
(for example) and override the method public CharSequence getPageTitle(int position)
to provide a title for each tab.
Hope it helps.
Upvotes: 8