解决ExpandableListView的OnItemLongClickListener无法准确获取position的问题

expandableListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
                long packedPosition = expandableListView.getExpandableListPosition(position);
                int groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
                int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
}



if ( childPosition == -1){
    //点击的是groupView
}else{
    //点击的是childView
}


你可能感兴趣的:(Android,经验心得)