问题
I have a expandable listview with textviews as rows and a webview as a child of each row (group). when user cliked on a group (row) webview with html loaded. after scrolling the webview towards end and then clicking another row doesnot show the group at top. it automatically scrolls down.
I want to scroll upwards so till currently selected group is at top.
thanks
回答1:
You need to implement OnGroupClickListener with return value true to prevent event flow. In the OnGroupClick you can use setSelectionFromTop(groupPosition, 0); to move just expanded group to the top of ExpandableListView. Also you need to call expandGroup() and collapseGroup() in the listener. But you should note what you will override general behavior of ExpandableListView in ItemClick event with expanding and collapsing groups, such as animate and etc.
回答2:
listView.setSelectedChild(selectedGroupNo, selectedChildNo, true);
does the trick.
来源:https://stackoverflow.com/questions/8988124/how-to-display-current-expanded-group-at-top-of-screen