0

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 ListActivity ? Should I reuse setListAdapter ?

1
  • setting new sorted adapter via setListAdapter will refresh your view Commented Mar 21, 2011 at 14:25

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

Sure he can, but should he? Mb there's more efficient way to reorder that list?
As the cursor is rebuilt, it's the simpliest way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.