Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Using ActionBar on older Devices

Author: Ian Darwin
Published? true
FormatLanguage: WikiFormat

Problem:

The ActionBar component, introduced in Honeycomb and upgraded in ICS, is a combination of a titlebar, menu items that get promoted to buttons, and a Menu Button to replace the hardware button that is absent in almost all 3.0+ devices. This is good functionality, and it would be nice to be able to use it on pre-4.x devices.

Solution:

There are two solutions:

  1. ActionBarCompat, a demo application (from Google) containing the classes you need;
  2. ActionBarSherlock, a third-party Android Library Project containing the compatibility classes.

Discussion:

ActionBarCompat is included in the Samples folder for each API that it works on. As in 1829 just download the samples for your API level (using the Download Manager), and create an "Android Sample Project" for ActionBarCompat. Run the app and you should see this admittedly simple view, regardless of API level.

ActionBarSherlock has a much larger download footprint, as a single GIT repository holds everything (including the projects complete web site, dozens of themes, dozens of test cases, etc.). You can download it from [1].

Note that neither is completely transparent - you both require the Support Library, and both require you to use a different parent class for your activity. A small price to pay for what you get!

No records found.