I have a menu created through:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(\"Email\");
return super.onCreateOptionsMenu(menu)
That won't work. You should define IDs for your menu items:
public static final int MENU_ADD = Menu.FIRST;
public static final int MENU_DELETE = Menu.FIRST + 1;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(Menu.NONE, MENU_ADD, Menu.NONE, "Add");
menu.add(Menu.NONE, MENU_DELETE, Menu.NONE, "Delete");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch(item.getItemId())
{
case MENU_ADD:
return true;
case MENU_DELETE:
return true;
default:
return super.onOptionsItemSelected(item);
}
}