开发者

Android sort ListView

开发者 https://www.devze.com 2023-02-18 22:01 出处:网络
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

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

精彩评论

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