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.
android:stackFromBottom="true"
before and the problem then is that if there was only a single element in my list view that it would be a the bottom of the screen. Thanks – Rentroll