android - How to change the order of the messages from JSON? -


i have such json response messages server:

response: {  count: 74246,  items: [{    id: 343194,    body: 'message 3',    user_id: 123,    from_id: 123,    date: 1436513626,    read_state: 1,    out: 0  }, {    id: 343190,    body: 'message 2',    user_id: 123,    from_id: 321,    date: 1436513502,    read_state: 1,    out: 1  }, {    id: 343187,    body: 'message 1',    user_id: 123,    from_id: 123,    date: 1436513198,    read_state: 1,    out: 0  }]  }

i put listview , have such order:

  • message 3
  • message 2
  • message 1

but want next order:

  • message 1
  • message 2
  • message 3

so means newest messages should bottom top. should build listview bottom? how? should achieve this? , sorry english :)

set reverse order on arraylist:

arraylist<your_model> mlist = new arraylist<your_model>(); 

set data in mlist json:

whenever want list on reverse order, put below code.

collections.reverse(mlist); 

hope you.


Comments