ArrayList<String> emplist = new ArrayList<String>();
//Inside the array I add list of employee that I query from DB
SubMenu empMenu = menu.addSubMenu("Employee's Map").setIcon(R.drawable.group);
for (int i = 0; i < emplist.size(); i++) {
empMenu.add(EMPLOYEE, i, i, emplist.get(i));
}
I prefer option for user that can select name of employee then I will perform result.
So, my question is how can I get the itemId which relate to user’s selected to use in onCreateOptionsMenu(Menu menu) Thank you for your suggestion.
You can override
onOptionsItemSelectedmethods in your Activity to get which menu item is selected by callinggetItemIdon themenuItemargument. Following is a sample code.