- What Is an Action Bar?
- How Do Action Bars Behave??
- Customizing Your Action Bar?
- Handling Application Icon Clicks on the Action Bar?
- Working with Screens that Do Not Require Action Bars
Working with Screens that Do Not Require Action Bars
Once you've set your application target to API 11 or higher, all your screens will have action bars by default. However, you can remove the action bar from a screen in several ways. Perhaps the simplest way is to turn it off programmatically from within your activity class. For example, we could turn off the action bar on the Vacuum screen with the following two lines of code added to the onCreate() method of the activity class:
ActionBar bar = getActionBar(); bar.hide();
This code will remove the entire bar from the top of the screen (Figure 2, bottom left). The application name will not be shown at all. You can also hide the action bar easily in layout files by creating a special custom theme. See the Android SDK documentation regarding removing action bars for details.
Advanced Action Bar Features
This tutorial only scratches the surface of what you can do with action bars. Action bars can be styled, including changes features like the background graphic and other customizations. They also support several other more sophisticated view types and widgets, beyond those menu items found in the options menu, such as tabs and drop-downs. You can even add other types of view controls to create functional areas of the action bar. See the Android SDK documentation regarding action bars for details.
Conclusion
If your application already uses options menus, adding action bar features when you begin to target Honeycomb devices is as easy as adding a few new attributes to your menu layout files. Action bars for individual screens are customizableas the developer, you can control which items are displayed and how they are displayed. You can even remove the action bar entirely, when you want more screen real estate for your full-screen game or media app!