Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add the Action bar in android 2.3 platform?

In my application i want to create an action bar which as my application icon and a view control. I refered so many tutorials and samples to create action bar but all of them have a plenty of code. I have also read the ActionBarSherlock but this need minsdkversion 15 to compile the libraries. Because i am new in android therefore i need a step by step tutorial to create a simple action bar. If you know a simple and easy tutorial to create action bar using xml then please post your answer.

like image 903
Naveen Chauhan Avatar asked May 28 '12 12:05

Naveen Chauhan


People also ask

How do you add action items to the action bar in Android?

All action buttons and other items available in the action overflow are defined in an XML menu resource. To add actions to the action bar, create a new XML file in your project's res/menu/ directory. The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar.

Where is action bar in Android?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.

How do I replace my action bar toolbar?

To replace an app's default action bar with a Toolbar : Create a new custom theme and modify the app's properties so that it uses this new theme. Disable the windowActionBar attribute in the custom theme and enable the windowNoTitle attribute. Define a layout for the Toolbar .


1 Answers

I've used this library for adding an action bar to 2.2+ apps:

https://github.com/johannilsson/android-actionbar

I found it easy to use and visually appealing, although the style of it does not exactly match the default action bar in ICS.

like image 94
Ian Newson Avatar answered Oct 21 '22 03:10

Ian Newson