Android RecyclerView ItemTouchHelper revert swipe and restore view holder

KuKaBi picture KuKaBi · Aug 3, 2015 · Viewed 28k times · Source

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.

Answer

DariusL picture DariusL · Aug 22, 2015

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.