You should also read

Try it out

Swipe views provide lateral navigation between sibling screens such as tabs with
a horizontal finger gesture (a pattern sometimes known as horizontal paging). This lesson teaches
you how to create a tab layout with swipe views for switching between tabs, or how to show
a title strip instead of tabs.

Implement Swipe Views

You can create swipe views in your app using the ViewPager
widget, available in the
Support Library. The
ViewPager is a layout widget in which each child view is
a separate page (a separate tab) in the layout.

To set up your layout with ViewPager, add a
<ViewPager> element to your XML layout. For example, if each page in the swipe view
should consume the entire layout, then your layout looks like this:

How you handle the ActionBar.TabListener callbacks to change tabs
depends on how you've constructed your content. But if you're using fragments for each tab with
ViewPager as shown above, the following
section shows how to switch between pages when the user selects a tab and also update the selected
tab when the user swipes between pages.

Change Tabs with Swipe Views

@Override
public void onCreate(Bundle savedInstanceState) {
...
// Create a tab listener that is called when the user changes tabs.
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
// When the tab is selected, switch to the
// corresponding page in the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
...
};
}

Likewise, you should select the corresponding tab when the user swipes between pages with a
touch gesture. You can set up this behavior by implementing the
ViewPager.OnPageChangeListener interface to change
the current tab each time the page changes. For example:

Use a Title Strip Instead of Tabs

If you don't want to include action bar tabs and prefer to provide
scrollable tabs for a shorter
visual profile, you can use PagerTitleStrip with
your swipe views.

Below is an example layout XML file for an
activity whose entire contents are a ViewPager and a top-aligned
PagerTitleStrip inside it. Individual pages (provided by the
adapter) occupy the remaining space inside the ViewPager.