Menu item IDs in an Android library project?

后端 未结 1 989
误落风尘
误落风尘 2021-02-03 21:13

The Android app uses a library project to contain most of the app code, as there are two versions of the app built from the core source. Since an IntelliJ IDEA update (to v11) I

相关标签:
1条回答
  • 2021-02-03 21:59

    Substitute the switch with an if/else if construct.

    int id = item.getItemId();
    if(id == R.id.menu_item_one) {
        // ...
    }
    else if(id == R.id.menu_item_two) {
        // ...
    }
    

    This is neccessary since ADT 14 because the final modifier was removed from id's in the R class.

    See Non-constant Fields in Case Labels

    0 讨论(0)
提交回复
热议问题