我在NavigationDrawer中有ExpandableListview。当组展开时,我会折叠先前展开的组,但是当折叠组时,展开的组会失去焦点(ExpandableListview的位置会下降)。这是代码:
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
if (mListView.isGroupExpanded(i)) {
mListView.collapseGroupWithAnimation(i);
} else {
mListView.expandGroupWithAnimation(i);
if(i!=lastExpandedGroupPosition )
mListView.collapseGroupWithAnimation(lastExpandedGroupPosition);
lastExpandedGroupPosition = i;
}
return true;
}
答案 0 :(得分:0)
扩展列表时,将函数setSelectedGroup(groupPosition)
与expandablelistview
对象一起使用。这将为群组设定焦点,即您点击的视图!
快乐的编码:)