Reverse the order of ListView display

穿精又带淫゛_ 提交于 2019-12-06 14:26:17

The order of a list is dependent on how you structure your SQL Query. Specifically one that impacts this exactly is the Sort parameter inside of the SQLite query method. The last parameter is the column to sort by, depending on what this column is in your database it will sort it by that.. For example:

[database object].query(.., COL_NAME + " ASC");

COL_NAME is the name of the column and ASC stands for 'Ascending Order'

I believe its DESC for 'Decending Order'.

Remember that the column needs to be an integer, string, or a date. SQLite will use these attached with the Ascending Or Descending Parameter.

Hmmm. The provided answer isn't quite right as that changes the order in which records come out of the database. Imagine the original question author has 50 records in his database and he wants to pull out the 10 newest items from the database everytime, but let the user change the way those 10 items are displayed. He would not want to change his SQL query.

Or resort Hashmap in reversed order. Good alternative if you have fixed Database-results.

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