I have an onclick function for my menu but I can't figure out what the ID is for my submenu so that I can tell the submenu what to do when the user click on it. I created my submenu programmatically using the code below. So if someone could please explain to me how I know what the id is for each item of the submenu I'd greatly appreciate it.
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
SubMenu submenu = menu.addSubMenu(0, Menu.FIRST, Menu.NONE, "Preferences");
submenu.add(0, Menu.FIRST, Menu.NONE, "Get Last 5 Packets");
submenu.add(0, Menu.FIRST, Menu.NONE, "Get Last 10 Packets");
submenu.add(0, Menu.FIRST, Menu.NONE, "Get Last 20 Packets");
inflater.inflate(R.menu.mainmenu, submenu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// Handle item selection
switch (item.getItemId())
{
case R.id.viewKML:
viewKML();
return true;
default:
return super.onOptionsItemSelected(item);
}
}