Enable OnItemLongClickListener even in action mode CHOICE_MODE_MULTIPLE_MODAL

I registered OnItemLongClickListener in listview, but when the listener is not called in actionmode.

This is the expected behavior, as shown in the perfromLongPress method .

Does anyone know how I can get a lonk click listener to be called?

The reason I want this behavior is to make selecting multiple files with one long click. See the QuickPic app for an example .

+3
source share
1 answer

I think you should use the registered instead of MultiChoiceModeListener and override its method:

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        // this is where you will inflate the CAB just in case
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {

        }
-1
source

All Articles