Before marking this question duplicate, I know there are few threads going on this particular topic but they are few years old (2012-13) and the Android APIs have changed since then. Furthermore, I have tried those resolutions but either they are not working anymore or since I have bound my ExpandableListView
with an ExpandableListAdapter
(extending BaseExpandableListAdapter
), the solutions are not working.
Here is my problem:
I have one ExpandableListView
fetching data from static file with the help of ExpandableListAdapter
extending BaseExpandableListAdapter
.
I have implemented getChildView()
and getGroupView()
methods within the adapter to show the Group Items and Child Items.
What I am not able to achieve is the smooth auto scrolling of the selected clicked item to the top. Something like this: Auto scrolling in ExpandableListView
The solution listed in above thread (ListView.setSelection(position)
) is not working in my case. I have tried it. Similarly solution like (android:transcriptMode="disabled or smoothScroll or normal"
) or (ExpandableListView.smoothScrollToPositionFromTop(scrollTo, 0)
) are not giving the desired results. I am not sure what wrong. There is no error or warning or anything.
There are few threads that says to call your ExpandableListView
in onGroupExpand()
method of the adapter. First, this method is no longer there but I suppose they are referring to the now getChildView()
method. But here the items are fetched from the View convertView
which is the XML layout of the child items and I don't have ExpandableListView
in this layout. I have it in my MainActivity
.
Maybe I am getting confused somewhere for this simple issue. Can someone please guide what I am missing and how I can achieve the desired results?