0

My problem is - I've got an ExpandableListView and want to use Contextual Action Bar (CAB) on it's child items. The bad thing is - the group items are also get selected by long-click, which is bad for me. So is there any way to make them non-selectable while in ActionMode? I tried to use onItemLongClick; tried onLongClick inside getGroupView. Tried some other tricks but failed.

If you find this impossible - maybe there is a way to make all the child items within the selected group be selected as well? That could be a solution, but I could not do that niether. Thank you.

1 Answers1

0

Solved. What I did is the next:

public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
                        boolean checked) {
    int type = ExpandableListView.getPackedPositionType(id);
    if (checked && type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        elvBankBranches.setItemChecked(position, false);
            return;
        }
}

When item is checked - I check if it is a grouop - and if it is - just uncheck it. Works fine. Note! - when uncheck the item in code - this method onItemCheckedStateChanged will be triggered once again!

Hope it helps someone )