开发者

Changing the order in a ListActivity

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜