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
.
精彩评论