Apr 5, 2014 - Update
With most recent ADT version (22.6.2 at the time of writing), steps listed below are simplified a lot. Setting up the v7 appcompat library project is enough to let you create a swipe views UI project compatible with Android versions down to 8. So, forget about additional steps, and simply follow what is described on Android developer web site.
Jan 6, 2014 - Original article
For recent versions of Android (more recent than 11), it's really easy to set up a project presenting a swipe views UI. But supporting older versions as well (version 8, for instance) is somehow tricky. Here is the way I tried:
- set up a compatibility library project, as explained in section Adding libraries with resources (same libraries). Resulting library project is named android-support-v7-appcompat.
- using Android wizard, create the project SwipeTest:
- minimum required SDK: API 11
- target SDK: API 18
- compile with: API 19
- theme: Holo Light with Dark Action Bar
- create activity: a blank activity with navigation type set to Fixed Tabs + Swipe
- right-click on the newly created project, select Properties > Android > Library and click on Add... button.
- add android-support-v7-appcompat library.
- in MainActivity source code, replace following import statements:
- android.app.ActionBar by android.support.v7.app.ActionBar
- android.app.FragmentTransaction by android.support.v4.app.FragmentTransaction
- instead of inheriting from FragmentActivity, extends ActionBarActivity
- in the onCreate() method, replace call to getActionBar() by a call to getSupportActionBar()
- open the Android manifest. On Manifest tab, click on Uses Sdk. For Min Sdk Version, replace 11 by 8.
- on Application tab, replace @style/AppTheme theme by @style/Theme.AppCompat
- save
That's it! This project now runs on latest versions of Android, and on Android 2.3.3.
Reference information: