Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reordering Lists like playlists in the media player

I have a list of items that are displayed using a ListView from a SQLCursor. The SQL table includes(as well as other things) a _id field and an order field. I use the order field to sort the list before it gets to the ListView.

What I need is a widget like the MediaPlayer has in its playlist view. It allows you to click the icon and drag the item in the playlist around and put it into a new order. With that ability I can then retrieve the new order and update the SQL table with the new order. However, I am not having any luck finding any clues to help me add that functionality into my program.

The question is whether I can use existing functions to help me, or do I need to manually program motion events and such until I get nearly the same functionality.

like image 630
CrazyBS Avatar asked Apr 01 '10 23:04

CrazyBS


1 Answers

However, I am not having any luck finding any clues to help me add that functionality into my program.

If you want the functionality from the Music application (which, by the way, is not named "MediaPlayer"), go look at its source code. Here is a StackOverflow question with answers that point you to the specific class (TouchInterceptor) that enables the drag-and-drop.

The question is whether I can use existing functions to help me, or do I need to manually program motion events and such until I get nearly the same functionality.

If you are looking for a widget with built-in drag-and-drop, there is none in the SDK.

like image 159
CommonsWare Avatar answered Oct 29 '22 00:10

CommonsWare