After calling notifydatasetchanged();
I want to scroll to the bottom of list so that user see the last record in the Listview.
(I am writing Chat module so for that purpose I need latest record at the bottom of list to be visible)
Can any one guide me how to achieve this?
position. maxScrollExtent; This simply means we are asking for the last position in the ListView via ScrollController. And then, we asked the ScrollController to move the position we got above using the jumpTo function.
A ListView in Android is a scrollable list used to display items.
I know that this has been answered and you took the answer and it was more than a year ago. But a better way to do this is Transcript Mode. For a demo, see the Android API Demo under Views > Lists > Transcript.
You would set the following on your list view in the XML.
android:stackFromBottom="true" android:transcriptMode="alwaysScroll"
It will always work whenever you call notifyDataSetChanged()
. You can set android:transcriptMode
to normal
instead if you want an even better result for chat applications: it will scroll to the bottom only if the last item was already in view. That way your users can view the previous chat without interruption when other users chat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With