反向的ListView显示的顺序 [英] Reverse the order of ListView display

查看:128
本文介绍了反向的ListView显示的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SimpleCursorAdapter从SQLite数据库检索信息,并把它变成一个ListView。这是所有教科书的东西:

I have a SimpleCursorAdapter to retrieve information from a SQLite database and put it into a ListView. It's all textbook stuff:

            new SimpleCursorAdapter(this, R.layout.viewexisting, c, from, to);

不过,我很乐意为它反向显示数据。此刻在数据库中的最旧的条目出现在顶部,和最新出现在底部。

However, I would love for it to display the data in reverse. At the moment the oldest entry in the database appears at the top, and the newest appears at the bottom.

推荐答案

一列表的顺序取决于你如何组织你的SQL查询。特别一说的影响这恰恰是SQLite的查询方法里面的排序参数。最后一个参数是按列进行排序,这取决于此列在数据库中它将被那种吧..例如:

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 是列的名称和 ASC 表示升序

我相信它的 DESC 作为Decending订单。

I believe its DESC for 'Decending Order'.

记住,列需要是一个整数,字符串或日期。 SQLite的将使用这些附加与升序或降序参数。

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

这篇关于反向的ListView显示的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆