What Is the Equivalent of Actionbar in Earlier Sdk Versions

What is the equivalent of ActionBar in earlier sdk versions?

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.

Sample Image

How do I use the ActionBar on older versions of Android?

Use ActionBarSherlock.

  • Make sure your project uses Android 4.0+ as the build target and that you have the compatibility/support library added. (You can right-click the project, select Android Toots > Add Support Library)
  • Download the ActionBarSherlock library project and import it into Eclipse.
  • Right-click your main project, select Properties, and select Android in the left pane. In the bottom half of the window, click the Add button and select the ActionBarSherlock project. Click OK.
  • Instead of using regular Activities and Fragments, you use ones from the Sherlock Library. They have the same names, but prefixed with "Sherlock" (SherlockActivity, SherlockFragment, etc.)
  • To access the actionbar in code, you call getSupportActionBar(). This returns either the regular actionbar (for Honeycomb and later) or the Sherlock actionbar (for pre-Honeycomb).
  • Theming instructions are on the ActionBarSherlock website.

Using actionbar before API Level 11

Have a look at ActionBarSherlock. Just add the library to your Android project and overwrite Activity with SherlockActivity, so you have all the possibilities of an Actionbar.

ActionBar compatibility available in

You have to use ActionBarSherlok. Which more easy to use, and works on all platforms.

Difference between ActionBarSherlock and ActionBar Compatibility

ActionBarSherlock gives your application an action bar regardless* of what version of the android API your app is being run on. Action Bar Compatibility gives you the action bar only if the device that you're running on is API level 3.0 or above.

*Note that if the device you're running on isn't 3.0 or above, ActionBarSherlock is going to use it's own custom implementation of the action bar, not a native one.

--EDIT--

It appears things have changed and there is actually no difference between ActionBarSherlock and the Action Bar Compatibility anymore. Please read the comments below for details.

--EDIT--

After having used both now, I can say that I actually prefer ActionBarSherlock to Action Bar Compatibility. ActionBarSherlock is really easy and nice to use.

--EDIT--
As LOG_TAG mentioned, there is now support for the action bar in the Android Support Library. I haven't had a chance to use it yet, but I would imagine that's the best one to use.

ActionBar - Android Tablet 2.3 and 4.0

Now, you can also use ActionBarCompat library from Android Support package. It's v7 version now supports ActionBar. Android dev team published a really useful introduction video video about using ActionBarCompat

Android ActionBar Compatibility

You shouldn't change the api version. The manifest declares min-sdk-version as 4, which means it will work on 2.x devices. Try loading it on the emulator, using api version 14 to compile.

How to have ActionBar like Google Play in pre HoneyComb devices ( 2.2)?

After considering that I decided using ActionBarSherlock, It is really easy to implement and to extend as well...

Action bar: Best practice for older Android versions

You might want to checkout the ActionBarSherlock. The source code is available here. It will give you an idea of how it is used along with fragments. It will give you some idea on how to proceed.

There is an android compatibility library which google created to use some of the new API's they created for honeycomb on lower version such as 1.5 and above. It can be found in the android sdk folder like E:\Program Files\Android\android-sdk-windows\android-compatibility\v4\android-support-v4.jar. If you don not have this jar you will need to download it using the avd manager.



Related Topics



Leave a reply



Submit