Android RecyclerView ItemTouchHelper revert swipe and restore view holder

Issue

Is there a way to revert a swipe action and restore the view holder to its initial position after the swipe is completed and onSwiped is called on the ItemTouchHelper.Callback instance? I got the RecyclerView, ItemTouchHelper and ItemTouchHelper.Callback instances to work together perfectly, I just need to revert the swipe action and not remove the swiped item in some cases.

Solution

After some random poking I found a solution. Call notifyItemChanged on you adapter. This will make the swiped out view animate back into it’s original position.

Answered By – DariusL

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published