how to display current expanded group at top of screen

穿精又带淫゛_ 提交于 2021-02-19 08:44:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!