如何在没有第3方lib的情况下在RecyclerView项目上滑动手势 [英] How to do swipe gesture on RecyclerView item without 3rd party lib
问题描述
他们是否直接支持RecyclerView项目上幻灯片的删除/存档(从右到左或从左到右)。
Is their any direct support for slide to delete/archive (right to left or left to right) on RecyclerView item.
而不是我想要的删除/存档列表项下的四个按钮。
And instead of delete/archive I want four buttons under the list item.
类似这样的 https:// github .com / 47deg / android-swipelistview ,但对于recyclerview和官方支持,没有任何第三方lib
something like this https://github.com/47deg/android-swipelistview but for recyclerview and official support not any 3rd party lib
推荐答案
是的是的,您可以使用 ItemTouchHelper 进行操作支持库提供的课程。
Yes there is, you can do it with ItemTouchHelper class provided by the support library.
PS
前几天我不得不这样做,并且还想尽可能避免使用3rd party lib。该库可能做的事情远远超出您的需要,因此,它可能比您的情况要复杂得多。它还可能不必要地增加方法数量。这只是为什么应该避免添加lib作为解决问题的快速解决方案的原因的一个示例。
P.S. I had to do this the other day and also wanted to avoid using 3rd party lib if possible. The library might be doing much more than you need and because of that it might be more complex than necessary in your case. It can also unnecessary grow your method count. This is just a sample of reasons why you should avoid adding lib as a quick fix for your problem.
编辑:我已经尝试过了,请参见此博客文章和此< a href = https://github.com/nemanja-kovacevic/recycler-view-swipe-to-delete rel = nofollow noreferrer> github存储库。
I had a go at this, see this blog post and this github repo.
这篇关于如何在没有第3方lib的情况下在RecyclerView项目上滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!