本文介绍了在OnGroupClickListener中单击组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检索在ExpandableListView的OnGroupClickListener中单击的组。
How can I retrieve the group clicked in a OnGroupClickListener of a ExpandableListView.
我已经尝试了parent.getItemAtPosition(groupPosition)并返回组和子项,所以我认为我必须将groupPosition转换为适配器中的绝对位置,但我不知道该怎么做。
I have tried parent.getItemAtPosition(groupPosition) and it return groups and childs so I think I must convert the groupPosition to a absolute position in the adapter, but I don't know how to do it.
new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
Item item= parent.getItemAtPosition(groupPosition);
return true;
}
}
推荐答案
尝试这个:
new OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
Object object = parent.getExpandableListAdapter().getGroup(groupPosition);
....
....
return true;
}
}
这应该有效。
这篇关于在OnGroupClickListener中单击组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!