C
C
CloudMonster2015-03-20 09:37:17
Android
CloudMonster, 2015-03-20 09:37:17

How to keep focus on an open ExpandableListview?

I have an ExpandableListview inside a NavigationDrawer. When opening a group, I close the previous open group, but when the group is closed, the open group loses focus (the position of the ExpandableListview goes down). Here is 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;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
one pavel, 2015-03-20
@onepavel

ExpandableListView has setSelectedGroup setSelectedChild methods, maybe they will help return focus after animation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question