Chintan
Chintan

Reputation: 936

How to add additional menu items in Android app?

I already have action bar with 4 menu items with image on my application screen. I want to add few more items but not in the action bar but these new items should be displayed when user click on "Menu" button on phone.

I have below property in manifest.xml:

android:uiOptions="splitActionBarWhenNarrow" 

Inside activity, I have below code.

final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);

Also, I am overriding, onCreateOptionMenu(Menu menu) for displaying action bar items. How can I do that?

Upvotes: 1

Views: 200

Answers (1)

codeMagic
codeMagic

Reputation: 44571

In your menu xml add

android:showAsAction="never"

for each item that you want in the button and they will be added to your overflow menu or menu button

Upvotes: 2

Related Questions