cancel
Showing results for 
Search instead for 
Did you mean: 

Drag elements between lists

heyo
Senior

save.png

Hello, I created two list, in picture I marked red and I want to drag list element to another and put element from list1 to list2. Is it possible? if not, maybe someone knows another idea?

1 REPLY 1
GaetanGodart
ST Employee

Hello @heyo ,

It seems feasible to me!
You can make your listLayouts clicklistener.
Here is the documentation for it :
 - clickListener developement guide 
 - clickListener API 

This will allow you to track clicks (and their location) and release (and their location).

The clickListener callback will only be called if a click happens inside the widget set as clickListener. From there you can wait for a "release" event and check it's location. Finally, compare that location with the coordinates and size (width and height) of your second listLayout to see of the release was made inside the second listLayout.
If that is the case, you can then call the method remove and the method insert to swap the widget that has to be moved.

The hard part will be to know which widget (the one you want to move) was clicked on (especially if your listLayout is scrollable).
Another consideration will be the position of the inserted widget.

Hope this helps.
Don’t hesitate to give us a feedback or give more precisions and tell us if the issue is solved! :smiling_face_with_smiling_eyes:

Gaetan Godart
Software engineer at ST (TouchGFX)