反向的ListView显示的顺序顺序、ListView

由网友(ドーナツ(甜甜圈))分享简介:我有一个SimpleCursorAdapter从SQLite数据库检索信息,并把它变成一个ListView。这是所有教科书的东西:I have a SimpleCursorAdapter to retrieve information from a SQLite database and put it into a...

我有一个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.

阅读全文

相关推荐

最新文章