简体   繁体   English

从recycleVIew中删除项目的动画

[英]Animation for removing item from recycleVIew

I have the RecyclerView , ItemTouchHelper and ItemTouchHelper.Callback instances to work together, and on swipe to left the selected item supposed to be removed ( by this tutorial ). 我可以将RecyclerViewItemTouchHelperItemTouchHelper.Callback实例一起使用,并滑动一下以保留应该删除的所选项目( 通过本教程 )。 The removal animation works, but only partly. 删除动画有效,但仅部分有效。 First after swipe the item seems to be removed, but after that it reappers, and the list stays still the same: 首先,在滑动后似乎已删除了该项目,但随后重新排序,并且列表保持不变:

在此处输入图片说明

Why can it happen? 为什么会发生?

Ensure these two statements 确保这两个声明

 cartList.remove(position);
        // notify the item removed by position
        // to perform recycler view delete animations
        // NOTE: don't call notifyDataSetChanged()
        notifyItemRemoved(position);

are executing. 正在执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM