开发者

Changing the order in a ListActivity

开发者 https://www.devze.com 2023-01-23 04:41 出处:网络
I\'m writing a simple database app on Android.The main activity is just a list of products - a ListActivity using a CursorAdapter.How is the best way to go about changing the order of the list (is sor

I'm writing a simple database app on Android. The main activity is just a list of products - a ListActivity using a CursorAdapter. How is the best way to go about changing the order of the list (is sort by Price or ProductID or something). I'm guessing I need to exe开发者_运维技巧cute a new query to get a new cursor - or can I recycle things?


There are two options base specialized on your app:

  1. How many record in your db ( If your database too large, new query may take long time)
  2. Your app usual query to database to get data

New query is simple better if your database not too large and your app not usual query to get data. In otherwise try create custom adapter


A cursor adapter - perfect! That means you're getting the list through a query. Just change the sort order. All commands that perform queries have an optional "sort order" parameter.

0

精彩评论

暂无评论...
验证码 换一张
取 消