How to create a ListView with draggable items?

I was looking for a ListPreference in which a user can reorder items from a list. Elements will be drag and drop and can be reordered by the user.

I saw this in my regular ROM (and I'm pretty sure I saw it in Cyanogenmod) for QuickPanel. Here is a screenshot to get this idea:

Screenshot of the "widget Button Order" in QuickPanel Settings of Sabotage ROM

I know how I can create custom ListView items and set an icon to indicate that items are being dragged, but I don't know how to drag them, and change the order accordingly. As for saving them in the settings, I found this one that can be easily implemented.

PS: , Cyanogenmod , :( , , this, - ...

.

UPDATE. . .

  • (ArrayAdapter ), , , ImageView TextView. .

  • DragListener RemoveListener, . ListView . .

  • , ViewGroup, , - , . ( onInterceptTouchEvent).

  • mRemoveMode = 1; TouchInterceptor : FLING = 0; SLIDE = 1; TRASH = 2;. , TRASH .

, Cyanogenmod, , , .

( r12, ):

, - :)

+5
1

, , AOSP, .

TouchInterceptor.java

, ListView MotionEvents , . , , TrackBrowserActivity.java.

, : DragListener, DropListener RemoveListener. , , , , SavedPreferences ( ListView ).

TouchInterceptor, , , .

+5

All Articles