So I'm trying to implement Drag-and-Drop within my To Do List app, but I am having trouble saving the order of the rows once moved - i.e. I moved the items, exited the app and it reverted back to its original position. I thought of a solution.
My Solution:
Create a column in my table: specified_position. Every time a row is moved, the onItemMove() method returns a fromPosition and toPosition. Move the row's position to toPosition, then increment/update all values there and above. Every time the table is read, it checks the positions and orders them according to it.
My Question:
Is my solution correct? Is there a better, easier even method instead to do this? Thanks lots!
Aucun commentaire:
Enregistrer un commentaire