ExpandableListView ChildView OnItemLongClickListener

来源:互联网 发布:淘宝店铺名称能修改吗 编辑:程序博客网 时间:2024/05/17 07:15

今天用到ExpandableListView,需要用到ExpandableListView 子View的长按,但是没有对应的方法可调。

网上查了一下,并没有查到完美又简洁的方法,后来还是朋友给我找到了答案,做个记录。

 

expandableListV.setOnItemLongClickListener(new OnItemLongClickListener(){public boolean onItemLongClick(AdapterView<?> parent, View childView, int flatPos, long id){if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD){long packedPos = ((ExpandableListView) parent).getExpandableListPosition(flatPos);int groupPosition = ExpandableListView.getPackedPositionGroup(packedPos);int childPosition = ExpandableListView.getPackedPositionChild(packedPos);showDeleteAlertDialog((AccountInfo) expAdapter.getChild(groupPosition, childPosition));return true;}return false;}});


 

原创粉丝点击