您好我是Android应用新手现在我很震惊地维护ExpandableListView ..群组没有崩溃,请让我知道如何解决此问题,在此先感谢
以下是我正在处理的代码,如果代码中有任何错误请告诉我
@Override
public void onGroupCollapsed(int groupPosition) {
super.onGroupCollapsed(groupPosition);
}
@Override
public void onGroupExpanded(int groupPosition) {
//if(IsExpanded)
//{
if(lastExpandedGroupPosition != -1 && groupPosition != lastExpandedGroupPosition){
onGroupCollapsed(lastExpandedGroupPosition);
}
else { super.onGroupExpanded(groupPosition); }
//}
lastExpandedGroupPosition = groupPosition;
}
答案 0 :(得分:3)
而不是
onGroupCollapsed(lastExpandedGroupPosition);
试
listView.collapseGroup(lastExpandedGroupPosition);
或者我认为除了Expanded之外你想要崩溃所有你可以使用这样的东西
public void onGroupExpand(int groupPosition) {
int lenght = adapter.getGroupCount();
for (int i = 0; i < lenght; i++) {
if (i != groupPosition) {
listView.collapseGroup(i);
}
}
}