android ExpandableListView position - packPostion - group/childposition

来源:互联网 发布:培训班排课软件 编辑:程序博客网 时间:2024/04/29 23:03

 ExpandableListView    的位置对应关系 绝对位置     flatPosition  就是scroll 时对应的位置

 

要转化成对应的   group  child position

 

packPosition=ExpandableListView    . getExpandableListPosition(flatPosition );

//判断位置类型 是group 还是child

ExpandableListView.getPackedPositionType(packPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP

ExpandableListView.getPackedPositionType(packPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD

ExpandableListView.getPackedPositionType(packPosition) == ExpandableListView.PACKED_POSITION_TYPE_NULL

 

groupPosition = ExpandableListView.getPackedPositionGroup(packPosition);// group节点位置
      childPosition = ExpandableListView.getPackedPositionChild(packPosition);// child节点位置

 

逆向转换

 

getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition)))

就能得到绝对位置

 

 

原创粉丝点击