ExpandableListView has a setOnChildClickListener method, but lacks of setOnChildLongClickListener method.
When I added setOnL
I was searching for this answer, but non here gave correct results.
Marked answer from tomash suggest completely different way. Answer from Nicholas is partially correct, but using 'id' is incorrect.
Correct, working, answer is: convert position parameter to packedPosition and THEN! using this new packedPosition value to obtain group and child ID's. Check code below
getExpandableListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
long packedPosition = getExpandableListView().getExpandableListPosition(position);
if (ExpandableListView.getPackedPositionType(packedPosition) ==
ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
// get item ID's
int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
// handle data
...
// return true as we are handling the event.
return true;
}
return false;
}
});
EDIT: I now see that autobot has almost correct solution, except testing getPackedPositionType on id and not on packetPosition