I was trying to implement long click event on Child items in ExpandableListView.
Seems that there is no special onChildItemLongClick event. So, searching internet helped to find an answer to the question Android: long click on the child views of a ExpandableListView?.
Second answer was exactly what I was looking for. In my implementation is looks as following:
getExpandableListView().setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) { // When clicked on child, function longClick is executed if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { int groupPosition = ExpandableListView.getPackedPositionGroup(id); int childPosition = ExpandableListView.getPackedPositionChild(id); longClick( expandableList, groupPosition, childPosition); return true; } return false; } });
To make a longClick in Group too, add the condition:
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
// Your logic here
return true;
}
Thanks!
To make a longClick call in group too, add the condition:
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
// Your logic here
return true;
}
Thanks!