Checking for which submenu user clicked in android
I have created a submenu using the manifest file. I have four text fields in my submenu. I want to know which submenu item the user clicked. I know about the switch case item.getItemId condition for the menu items. But i want to know how to check for which subme开发者_开发技巧nu the user clicked. Thanks for any help
You could save the id of the submenu item to a variable. For example:
int item;
@Override
public void onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.something: {
this.item = something;
return true;
}
}
Now the variable item contains the id of the item selected.
精彩评论