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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With