Drag items around in a ListView to change their order?

Question:

Let's say I have a ListView of items:
Cat
Dog
Mouse

And these are bound to the ListView via an adapter to a database.

What I want to be able to do is to be able to re-order the list view,. For example I want to somehow drag "Mouse" up to the top of the list above "Cat". Once I have an order set, I then want to "save" the list and its order back to the database.

Is there any way to do this? Has someone made such a custom ListView that I could use? The only alternative I can think of is to long press on a list view item and have a "Move up by one", "Move to top", etc. context menu that moves items around in the list.


Answer:

I have that stuff packaged up as a reusable component: github.com/commonsguy/cwac-touchlist

Comments

Popular posts from this blog

How to draw an overlay on a SurfaceView used by Camera on Android?

Create EditText with dropdown in android

Android TCP Connection Chat application