Android - Reverse listview as message display

前端 未结 4 754
北海茫月
北海茫月 2020-12-17 16:50

I\'ve got a little question for my Android App. I searched for a long time but found nothing about my problem.

Scenario : I\'ve to display a revert

相关标签:
4条回答
  • 2020-12-17 17:21

    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.

    0 讨论(0)
  • 2020-12-17 17:24

    For Kotlin is more easy just

     myList.reverse()
    
    0 讨论(0)
  • 2020-12-17 17:31

    do like this:

    Collections.reverse(YourList); // ADD THIS LINE TO REVERSE ORDER!
    YourList.notifyDataSetChanged;
    
    0 讨论(0)
  • 2020-12-17 17:45

    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.

    0 讨论(0)
提交回复
热议问题