38

Since the ActionBar is available only in Android 3.0 and later, what is a good way to implement ActionBar-like widget in earlier sdk versions? I am looking to do this programmatically, if that helps.

Suchi
  • 9,989
  • 23
  • 68
  • 112

4 Answers4

123

I have created a library, ActionBarSherlock, which is extended from the Android Compatibility Library to implement support for the native action bar all the way back to Android 1.6.

The key feature of this library is that it mimics the native action bar of Android 3.0+ and allows you to interact with it and theme it on all version of Android from 1.6 up through the current newest version, 3.1. There are samples and documentation on the website linked above which should give you a good idea about how it works.

You can also look on the implementations page on the GitHub wiki for real world applications of the library.

enter image description here

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • 2
    Hi Jake, your library looks cool. I have a question though, one not presently on your FAQ. Neither I nor Google can find any mention of licensing or rights on your site. Is this a donation to the community or are you charging for use of it? – JohnK Jun 28 '12 at 22:34
  • 11
    It's Apache 2.0 which is mentioned on GitHub and in the download. – Jake Wharton Jun 29 '12 at 07:46
  • 4
    One question Jake, why did you name it ActionBar Sherlock? Why Sherlock? Jokes aside, it is a great gift to all Android devs:) cheers man:) – Arif Nadeem Oct 10 '12 at 07:33
  • ABS is some great work !! – An-droid Apr 03 '13 at 08:36
  • @JakeWharton hi jake,your library helped me a lot to display action bar in android version(lower than 3.0).But one problem i faced.I want to display the title bar and i got success in displaying title in less than 3.0 version but while run on 4.0 or higher it throws exception you can't apply styles......(you must know this exception i guess).Any help. – Android Killer Apr 30 '13 at 10:37
14

The Google IO 2011 app is a good example

It runs on versions of Android less than 3.0 as explained during the Google I/O 2011 session, Designing and Implementing Android UIs for Phones and Tablets.

ImR
  • 787
  • 6
  • 8
user755499
  • 2,241
  • 4
  • 25
  • 34
  • 1
    Like I mentioned, the ActionBar is not available till Android 3.0. So this code would not work. I am developing in Android 2.2 – Suchi May 17 '11 at 20:09
  • If you looked at the source code of the Google IO 2011 app, you'd see that they do have an actionbar on all SDK levels. You'd also see that they implemented it themselves, and how to implement it with your own code. – Eagle Jul 31 '12 at 17:02
  • 6
    Google IO 2012 App uses ActionBarSherlock library http://code.google.com/p/iosched/source/browse/libprojects/abs/src/com/actionbarsherlock/ActionBarSherlock.java – Palani Aug 17 '12 at 15:27
9

Use android-actionbar or GreenDroid.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

The new Android support library adds ActionBar support back to API 7.

http://developer.android.com/tools/support-library/index.html

joey_g216
  • 796
  • 9
  • 23