Child selection in ExpandableListView

后端 未结 2 1179
慢半拍i
慢半拍i 2021-01-14 13:44

In an ExpandableListView is it possible to initially select a child item so that the containing group is expanded and the list is scrolled to this child\'s posi

相关标签:
2条回答
  • 2021-01-14 14:10

    Add a call to listView.expandGroup() before setSelectedChild().

    The shouldExpandGroup parameter set to true in setSelectedChild() seems only to work if there's at least one group expanded in the first place.

    0 讨论(0)
  • 2021-01-14 14:28

    In an ExpandableListView is it possible to initially select a child item so that the containing group is expanded and the list is scrolled to this child's position:

    //select child and open it's group
    ExpListView.setSelectedChild(groupPos, childPos, true);
    //scroll to selected child
    ExpListView.smoothScrollToPosition(ExpListView.getFlatListPosition(ExpListView.getPackedPositionForChild(groupPos, childPos)));
    
    0 讨论(0)
提交回复
热议问题