I am creating a Menu in Android XML and adding via code a submenu. Now I want that only one menu-point to be checked. In XML it would be android:checkableBehavior="single"
. But how can I realize this in code?
Use
MySubMenu.setGroupCheckable(int groupId, boolean checkable, boolean exclusive);
exclusive = true //to pick only one menu-point as android:checkableBehavior="single"
For example:
MySubMenu.setGroupCheckable(0, true, true);
*Add this function after all your submenu items were defined
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.