I have an ExpandableListView and I want to log the groupposition when clicking on a group. Unfortunately the code below returns always 0, as if I were clicking on the 0th group.
exList.setOnGroupClickListener(new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
groupPosition = ExpandableListView.getPackedPositionGroup(id);
Log.i("group position", groupPosition + "");
return false;
}
});
I also have a longclicklistener on the groups and childs which works right:
exList.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
groupPosition = ExpandableListView.getPackedPositionGroup(id);
...
}
Any ideas?