开发者

Android sort ListView

I have an ListActivity which use data from DB..

setListAdapter(new CursorAdapter(myCursor));

This view have a column with a numbers. What i need is to sort them in descending whey when i click on a button. Its not a problem to write a new select with a new sort type..But how to refresh ListA开发者_StackOverflow中文版ctivity ? Should I reuse setListAdapter ?


Since you are using a CursorAdapter it would be best to have the db sort the list. So just create a new Cursor and call setListAdapter again.


Yes you can reuse the setListAdapter() method, after recreating a new CursorAdapter with the new reordered Cursor.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜