--- title: Usage layout: default ---
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.
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.
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.
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:
android.support.v4.app.ActionBar
android.support.v4.view.Menu
android.support.v4.view.MenuItem
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.
For details on including the library in your application please see the download page.
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:
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.
getSupportActionBar()
exposes.