您的位置:首页 > 移动开发 > Android开发

ExpandableListView ChildView OnItemLongClickListener

2013-11-06 16:53 405 查看
今天用到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;
}

});


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐