Android submenu options for Android

So, I have a submenu that I have for the options menu item. I want a list of checked records that the user can select / deselect as much as they want. The only problem I cannot solve is how to prevent the options menu from closing when one of these checkboxes is clicked. I saw that the performShortcut parameter has the FLAG_PERFORM_NO_CLOSE flag, but I'm not sure how to use this method. I tried a lot of things, but I'm confused about where the keyevent was supposed to come from, or even if this is the right method that I should look at.

So tl; dr: How to prevent closing the menu / submenu of options when selecting an option?

+4
source share
1 answer

The way I will deal with this is to use the standard warning dialog box class. In your menu handler, create an AlertDialog and pass an array of your parameters to Builder.

The method you should pay attention to is AlertDialog.Builder.setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)

Pass an array to this method and put the submenu select code in the ClickListener.

0
source

Source: https://habr.com/ru/post/1315373/


All Articles