views:

98

answers:

1

I have an Android app where users can add items to a list, and I'd like them to be able to re-order the items in the list however they want (as opposed to just offering them different sort orders). It's easy enough to add a position setting for the items (they come from the DB) but what kind of UI elements are available for the user to indicate the desired ordering?

Is there a pattern anyone has seen implemented for this? I have not seen anything on Android that does anything like this, except the home screen which is similar but looks a little bit beyond my expertise at this point. The best I can think of is to use a long click and context menu to "move up" or "move down".

+1  A: 

Well, there's the right answer, and my answer. :-)

The right answer is drag-and-drop. There's some code for that floating around the Android source for the Music app, but it's outside my skill level with touch events right now.

In the one case I wanted this feature, I created a list using up/down buttons to let the user resequence. Ugly, but it works.

Using a context menu, as you indicate, can certainly be made to work, but if you can spare the on-screen real estate, putting the buttons on will be easier. You might even consider toggling the button visibility on/off via an option menu, if having them on-screen the whole time will be unpleasant.

And, someday, I hope to make a drag-and-drop ReorderableListView as a reusable component...but I wouldn't hold your breath. Maybe somebody else has one that I haven't run across yet.

CommonsWare
Dude, as many questions as you answer, how do you have time to actually code? :-) I guess that's as good as it gets... thanks for the tips.
sosiouxme