Android RecyclerView ItemTouchHelper还原滑动并还原视图持有人 [英] Android RecyclerView ItemTouchHelper revert swipe and restore view holder

查看:443
本文介绍了Android RecyclerView ItemTouchHelper还原滑动并还原视图持有人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以还原滑动动作并将视图持有人恢复到其初始位置 之后,并且在ItemTouchHelper.Callback实例上调用onSwiped?我已经将RecyclerViewItemTouchHelperItemTouchHelper.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆