ActionBarSherlock is a third-party Android Java library introduced by Jake Wharton (@/+), that enables convenient implementation of the Ice Cream Sandwich Action Bar to Android devices from version 1.6 (i.e. API 4) up, majorly through the use of the official v4 Support Library.

this post talks about how to get started using ActionBarSherlock.

bits better to have known before reading:

  • about ActionBar
  • about the v4 Support Library (supposedly aka Compatibility Library)
  • how to make a Hello World app

the purpose is to have the native ICS behaviour, look and feel on old devices, i.e. supposedly as old as Android 1.6, i.e. API 4. i am testing on Android 2.3 Gingerbread, i.e. API 9.

  1. create Android application project from existing code using the /library folder from the downloaded ActionBarSherlock zip/tarball.
  2. make sure for this project, the Build Target is exactly Android 4.0, i.e. API 14.
  3. make sure this project has "Is Library" ticked (under right-click, "properties" , Android).
  4. add the Compatibility Library to the ActionBarSherlock project. to do this in eclipse, right-click on this project in the project explorer panel, go to "Android Tools" -> "Add Support Library". (internet connection normally needed.)
  5. create your own project (e.g. "myProj"). use a Build Target no lower than API 14, and use a MinSDK version that suits your need - which in my case is API 9. the API levels are simply stated in the Manifest.xml file.
  6. add the ActionBarSherlock project as a library for your myProj. (under right-click, "properties" , Android)
  7. in your myProj, extend all your activities with "SherlockActivity" instead of "Activity". there are also all sorts of SherlockBlablabla, just take guesses yourself.
  8. modify your myProj's Manifest.xml file. for the <application>, add or edit so that you have the attribute
    • android:theme="@style/Theme.Sherlock"
    • here, Theme.Sherlock has a variety of alternatives, e.g. Theme.Sherlock.Dark.ForceOverflow, Theme.Sherlock.Light.DarkActionBar.
  9. done. do whatever you want as if you're in ICS altogether - just make sure you are using Sherlock or Support-v4 imports instead of normal Android ones when you have a choice. (common ones are Activity, Fragment, Menu.)

reference: