Search code examples
androidmenuactionbarsherlock

How can I add a menu item to the action bar with actionbarsherlock?


I have started my android application with the standard holo theme. Then I added the tabs functionality and now I would like to add a small settings button in the action bar.

How can I do that. I already set this method:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
   com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
   inflater.inflate(R.menu.activity_main, (com.actionbarsherlock.view.Menu) menu);
   return super.onCreateOptionsMenu(menu);
}

Solution

  • Try this:

    menu.add("some title").setIcon(R.drawable.[your image]).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);