Current,I am having a problem when execute drag and drop item in recyclerview. I am doing with reference from https://github.com/iPaulPro/Android-ItemTouchHelper-Demo But when execute function in adapter:
mListBookMark is ArrayList of Object
@Override
public boolean onItemMove(int fromPosition, int toPosition) {
Collections.swap(mListBookMark, fromPosition, toPosition);
notifyItemMoved(fromPosition, toPosition);
return true;
}
When I drag item from position a to position b but when finish drag recycler view not data changed. How must I do? Please give some suggestion for me! Thank you.
Try adding notifyItemChanged()
to your code, like this:
@Override
public boolean onItemMove(int fromPosition, int toPosition) {
Collections.swap(mListBookMark, fromPosition, toPosition);
notifyItemMoved(fromPosition, toPosition);
notifyItemChanged(fromPosition);
notifyItemChanged(toPosition);
return true;
}
This should update the views based on their new position.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With