wouter88
wouter88

Reputation: 1294

Android - drag and drop - list rearrange

How can I create a list where I can rearrange list items with dragging list rows to another row and so on (to change to order)?

Just like on the HTC Hero in the clocks app where you can rearrange the order of clocks?

Upvotes: 24

Views: 36865

Answers (5)

CaseyB
CaseyB

Reputation: 25058

It's in platform/packages/apps/Music/src/com/android/music/TouchInterceptor.java. Here's a direct link:
https://android.googlesource.com/platform/packages/apps/Music/+/master/src/com/android/music/TouchInterceptor.java

Upvotes: 2

heycosmo
heycosmo

Reputation: 1388

You can also try my recent implementation here:

It gives smooth scrolling while dragging and supports list items with arbitrary heights. Lots of jumpy behavior has also been removed as compared to the TouchInterceptor.

Upvotes: 11

Bo.
Bo.

Reputation: 580

Pay special attention to this one

com.android.music.TouchInterceptor

Upvotes: 20

ericharlow
ericharlow

Reputation: 2065

Even though this question is already answered. I struggled using the music app as an example, so I created a simple Drag and Drop List project to help others that can be found here

Upvotes: 34

yanchenko
yanchenko

Reputation: 57166

Hint: download the android sources and have a look how the Music app (packages\apps\Music) implements this functionality.

Upvotes: 1

Related Questions