Android RecyclerView ItemTouchHelper还原滑动并还原视图持有人 [英] Android RecyclerView ItemTouchHelper revert swipe and restore view holder
问题描述
是否有一种方法可以还原滑动动作并将视图持有人恢复到其初始位置 之后,并且在ItemTouchHelper.Callback
实例上调用onSwiped
?我已经将RecyclerView
,ItemTouchHelper
和ItemTouchHelper.Callback
实例完美地结合在一起,我只需要恢复滑动动作,并且在某些情况下不删除滑动项即可.
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.
推荐答案
经过一些随机戳戳后,我找到了解决方案.在适配器上调用notifyItemChanged
.这样一来,向外滑动的视图便会恢复原来的位置.
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.
这篇关于Android RecyclerView ItemTouchHelper还原滑动并还原视图持有人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!