将焦点集中在ExpandableListView中的扩展组上

将焦点集中在ExpandableListView中的扩展组上

本文介绍了将焦点集中在ExpandableListView中的扩展组上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NavigationDrawer中具有ExpandableListview.当组展开时,我折叠了以前的展开组,但是当组折叠时,展开的组失去了焦点(ExpandableListview的位置下降了).这是代码:

I have ExpandableListview inside NavigationDrawer. When group is expanded I collapse the previous expanded group, but when group is collapsed expanded group loses the focus (position of ExpandableListview goes down). Here's the code:

@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;
}

推荐答案

在扩展列表时,将函数 setSelectedGroup(groupPosition) expandablelistview 对象一起使用.这将为该组设置焦点,您单击的是谁的视图!快乐的编码:)

Use the function setSelectedGroup(groupPosition) with the expandablelistview object while expanding the list. This would set the focus for the group , who's view you had clicked!Happy coding :)

这篇关于将焦点集中在ExpandableListView中的扩展组上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:13