--- title: Usage layout: default ---

Usage

Sticking with the theme of the official compatability library, ActionBarSherlock aims to allow the use of the action bar design pattern by mimicking the experience that would be found natively on Android 3.0+ with as little effort as required.

Requirements

All of the requirements of implementing the compatability libary are present in this library. If you are unfamiliar with them please read its "Using Some of the Library APIs" guide.

The only additional requirement that ActionBarSherlock imposes is that any activity on which you would like the action bar attached define a theme in the manifest that is either one of the two provided or be a custom theme whose parent is one of the two provided. See the theming page for more details on implementing this.

Action Bar API

When creating an activity to use the action bar on all versions of Android, you must declare your activity to extend the FragmentActivity class (instead of the traditional Activity class). Interaction with the action bar is handled by calling FragmentActivity.getSupportActionBar() (instead of getActionBar()).

The API exposed by the ActionBar instance is an exact duplicate of that which the native method exposes. Refer to its documentation as well as the articles on how to utilize its functionality in the "Related Links" section.

Imports

In order to provide functionality that was not available on version of Android prior to 3.0, the library includes and uses a lot of classes that are named the same as their native counterparts. The three most common are:

It is important to ensure that you are using these types where appropriate since they contain the additional functionality required to support the action bar.

NOTE: The majority of errors regarding the @Override-ing of methods from FragmentActivity are a result of using the incorrect imports. All of the classes which exist in the android.support.v4 package whose names match that of a native class extend from that native class and as such can be used in their place.

Including In Your Project

For details on including the library in your application please see the download page.

See Also...

This library was meant to be as behind-the-scenes as possible and require a minimal amount of changes to support. The core usage of the action bar itself is no different than if you were interacting with the native action bar.

Be sure to also visit the following pages:

Related Links

The following links are useful information on how to operate the native action bar. Other than the small tweaks mentioned on this page, the entire API is exactly the same.

Class APIs

ActionBar
Main API for nearly all interaction with the action bar. This is the exact API getSupportActionBar() exposes.
Fragment
New fundamental building block of layouts which enable your to provide rich experiences on a range of different devices without code duplication.

Articles

Using the ActionBar
Broad introduction on the action bar design paradign, the API, and common use cases.
Creating Menus
Menus drive the action bar's items.
Using the Compatability Libary
ActionBarSherlock is a superset of the official compatability library. All features in the Google library are also available for use through this library.
Fragments
Introduction to utilizing this new modularized view and its lifecycle.