Search code examples
androiddrag-and-dropexpandablelistview

How to implement expandablelistview with Drag and Drop List Items in android


I wan for the ExpandableListView with Drag and Drop of ListItems in Android,i google it but i haven't found any good tutorial or any good link for ExpanadableListView with drag and drop list item. Please suggest me where can i learn to implement drag and drop for ExpanadableListView. Any tutorial,sample code would be appreciated greatly .Help me. Thank you.


Solution

  • The basic idea behind drag and drop can be divided into two sections, like updating the UI and updating the data. Updating UI starts with hiding the selected item and show a detached row with the same value as the hidden item, this will show that the selected item is ready to drag, now move the detached row over the list view based on the touchmove event, when the user takes the hand ie the touchup event or any other event that happens while dragging, get the current row at which user touched last , remove the detached row and do the data updation and invalidate the expandable listview, this will redraw the list based on the new set of data and the user will get a feeling that the item is dragged and dropped in the list.

    I have done something similar, see this