There is a custom adapter for a list of views in which messages are added. The sequence of messages comes from the top down. How to sort messages in a different order, new below? Such is the code ..

ArrayList<DialogSaveData> UpList = new ArrayList<>(); adapter = new CastomDialog(ChatActivity.this, R.layout.castom_dialog_list, UpList); //присваиваем адаптер списку chat.setAdapter(adapter); Cursor cursor = db.query("mess", null, "idto =? or idme = ?" , new String[]{idyou.replaceAll("\\s+",""),idyou.replaceAll("\\s+","")}, null, null, null); if (cursor.moveToFirst()) { do { UpList.add(0, new DialogSaveData( cursor.getString(cursor.getColumnIndex("idme")), cursor.getString(cursor.getColumnIndex("idto")), cursor.getString(cursor.getColumnIndex("data")), myLoginCript.replaceAll("\\s+",""), cursor.getString(cursor.getColumnIndex("status")) )); } while (cursor.moveToNext()); } 
  • 2
    read what a queue is, a stack. Perhaps you will find your solution there ... - michael_best
  • as an option, if we take values ​​from the results of a database query, you can simply reverse the sort by date (desc) in the query to the database. As a result, we will fill the sheet with data in the reverse order. - DimXenon

0