Action Bar Sherlock is a fantastic development by Jake Wharton. It is designed to build on the Android Compatibility Library (that makes Fragments available back to 1.6) and enables the Action Bar.
Here’s how I implemented it (there may be better ways):
1. Download the library from here
2. Unzip the file
3. Create a new project in Eclipse. Choose from existing source, and select the library folder inside the folder you just extracted.
4. Press next, select Android 4.0.3, press Finish
5. Check that the new project is a library (right click, properties, android, is library [tick])
6. If the project has error’s here’s a few things to check:
* Compiler compliance level should be 1.7 if available to select
* Check that the android-v4-support.jar is in the build path correctly
7. Now you have the library project setup (I called mine ActionBarSherlock)
8. In your apps project you’ll need to add ActionBarSherlock as a library (right click, properties, android, add, choose ActionBarShelock (or whatever you called the library project).
9. Ready to start using it.
10. In a simple app (not using fragments) change “extends Activity” to “extends SherlockActivity” (Ctrl+Shift+O in Eclipse will handle the imports).
11. Now to add the theme. ABS comes with it’s own themes so that previous Android OS’ can look like Android 4 (at least the Action Bar). To add the theme open your apps manifest file and add the following into the Application element:
android:theme="@style/Theme.Sherlock.Light"
or “Theme.Sherlock.Light.DarkActionBar” or “Theme.Sherlock” etc
12. Your app of course needs to be built against Android 4.0.3, then just change your minimum SDK to the lowest you want to support.
Thats about it. For apps using Fragments you’ll need to extend SherlockFragment / SherlockFragmentActivity etc.
One other thing… Eclipse cries like a little girl if the layout editor tries to use a Sherlock theme, to fix just use the official Holo / Holo Light theme from the dropdown list.
Further support can be found on the official Action Bar Sherlock website
Good luck.
The post Android Dev: Action Bar Sherlock appeared first on Droid App.