user2744199
user2744199

Reputation:

adding at the top of listView

I am using list View in my app ,When my application receives the messages they are stored in the database and then are added to the list view ,but every time app receive the new message they are stored at the end of the list which is not a good practise to store new message at end, I want to put my all new messages at the top of the list , what should I do to achieve this?

Upvotes: 0

Views: 62

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Use insert() on ArrayAdapter<> to insert at position 0, which will not only update the ArrayList<> that you are wrapping with the ArrayAdapter<>, but also will trigger your ListView to update and show the new entry.

Upvotes: 1

Related Questions