重新排列SimpleCursorAdapter列表视图项目 [英] Rearrange list view items in SimpleCursorAdapter
问题描述
我有一个数据库SQLite的,然后使用SimpleCursorAdapter,我显示的值到列表视图。不过,我要重新排列列表视图中的项目,并显示那些开始与ID#1顶部,然后ID号为2,等等..的问题是,我不能够把握的概念重新分配列表视图项基础关于从内容提供者的一些ID号。 如果你知道,请分享。谢谢。
I have a database SQLite and then using SimpleCursorAdapter , I display values into list view. However, I want to re arrange the list view items and display the ones starting with ID #1 in top and then ID number 2, so on.. the issue is, I am not able to grasp concept of re allocating list view items based on some ID number from Content provider. If you know , please share. Thank you.
推荐答案
如果你正在使用SQLite正确,你应该能够按ID为了做一个在查询了数据库。
If you are using SQLite correctly you should be able to do a "order by id" when you query up the DB.
如果那不是的话,那么我会做的是建立你的数据到一个集合。
If thats not the case then what I would do is build out your data into a collection.
让您的通用对象实现媲美接口。
Have your generic object implement the comparable interface.
像这样的http://www.java-tips.org/java-se-tips/java.lang/how-to-use-comparable-interface.html
当您的调用Collections.sort(contentfromtheprovider);它也会搜寻基于ID喜欢你想要做的事。
When you call Collections.sort(contentfromtheprovider); It will sort based on the ID like you wish to do.
这篇关于重新排列SimpleCursorAdapter列表视图项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!