0

I'm using the code from here: http://ericharlow.blogspot.com/2010/10/experience-android-drag-and-drop-list.html

It's very useful to me, but I'm not sure how to make any change to the listview persist. At first the items in the listview are ordered A,B,C and after the drag and drop C, B, A However if I quit this app and then restart it later the order goes back to A,B,C

I have the idea to use sql to save the listview id , so i can create table with id 1 2 3 which with content a b c in database , and then call to listview, so i can use the above code to drag , after i drag listview become c b a , but how to save the new sequences in database like id 1 2 3 with c b a ?

thanks

slayton
  • 20,123
  • 10
  • 60
  • 89
陳冠翰
  • 3
  • 2

1 Answers1

0

You don't necessarily have to use a sql database to accomplish this. Basically just save the data source for the listview whenever the activity is paused or stops. Then reload the data source when the activity starts up again. Look at this question for more information on how to do that: Saving Android Activity state using Save Instance State

Community
  • 1
  • 1
slayton
  • 20,123
  • 10
  • 60
  • 89