Android - Reverse listview as message display

孤者浪人 提交于 2019-11-29 06:12:39

I think you should look into using TranscriptMode and StackFromBottom with your listview:

android:stackFromBottom="true"
android:transcriptMode="normal"

By setting the transcript mode to normal it will scroll to the bottom only if the last item was already in view. That way your users can view the previous list view items without interruption when you call notifydatasetchanged.

do like this:

Collections.reverse(YourList); // ADD THIS LINE TO REVERSE ORDER!
YourList.notifyDataSetChanged;

I fixed this by using the same code as you included but I update the index variable by the number of items I add to the adapter before restoring the position. Seems to do the trick.

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