@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
/*
* menu.add(int groupId, int itemId, int order, CharSequence title);
*/
MenuItem menu0 = menu.add(0, 0, 0, "Action Item 0");
{
menu0.setIcon(R.drawable.ic_launcher);
menu0.setShowAsAction(
MenuItem.SHOW_AS_ACTION_IF_ROOM
|MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
menu.add(0, 1, 1, "Action Item 1");
menu.add(0, 2, 2, "Action Item 2");
menu.add(0, 3, 3, "Action Item 3");
menu.add(0, 4, 4, "Action Item 4");
return true;
}
Related article: Create ActionBar using XML