开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜