Rearrange list view items in SimpleCursorAdapter

前端 未结 2 1313
天命终不由人
天命终不由人 2021-01-22 16:32

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 wi

2条回答
  •  伪装坚强ぢ
    2021-01-22 17:29

    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.

    like so http://www.java-tips.org/java-se-tips/java.lang/how-to-use-comparable-interface.html

    When you call Collections.sort(contentfromtheprovider); It will sort based on the ID like you wish to do.

提交回复
热议问题