将重点放在ExpandableListView中的扩展组上

时间:2015-03-20 07:23:05

标签: android listview android-listview expandablelistview

我在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;
}

1 个答案:

答案 0 :(得分:0)

扩展列表时,将函数setSelectedGroup(groupPosition)expandablelistview对象一起使用。这将为群组设定焦点,即您点击的视图! 快乐的编码:)