Overflow menu item selection in TextView CustomActionModeCallback

I am trying to present a custom action bar with a long press on a text field. My menu contains more than 5 items, which is why some items are present in the overflow menu.

When I click the overflow icon, the action bar is destroyed and I cannot select any item inside the overflow.

    ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.add_rule_menu, menu);
            return true;
        }

        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            for (int i = 0; i < menu.size(); i++) {
                MenuItem item = menu.getItem(i);
                if (!mOptionsList.contains(item.getItemId()))
                    item.setVisible(false);
            }
            return false;
        }

        // Clicking on overflow button does not trigger this method at all.
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            switch (item.getItemId()) {
             // Rest of the code
            }
        }

        public void onDestroyActionMode(ActionMode mode) {}
    };

    textView.setCustomSelectionActionModeCallback(mActionModeCallback);
+4
source share
1 answer

I posted a question about this year ago that was never resolved.

. , , , , " ". RichEditText , . "format" setCustomSelectionActionModeCallback(). "" , , , , , .

+5

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


All Articles