Android Checkable Menu Item

后端 未结 9 1814
悲哀的现实
悲哀的现实 2020-12-01 00:59

I have the following menu layout in my Android app:




        
9条回答
  •  隐瞒了意图╮
    2020-12-01 01:58

    Layout looks right. But you must check and uncheck menu item in code.

    From the documentation:

    When a checkable item is selected, the system calls your respective item-selected callback method (such as onOptionsItemSelected()). It is here that you must set the state of the checkbox, because a checkbox or radio button does not change its state automatically. You can query the current state of the item (as it was before the user selected it) with isChecked() and then set the checked state with setChecked().

提交回复
热议问题