我希望我的RecyclerView项目向左滑动,必须有明星风格的checkBox显示,以添加到收藏夹列表。我正在使用Mike Penz的FastAdapter。我该怎么做呢?
发布于 2018-10-14 17:27:39
以下问题与适配器实现无关。Adapter本身的主要目的是提供这些项。例如,在FastAdapter中,适配器完全独立于任何UI。并且将只处理抽象元素。
View的工作是定义项目的外观和行为。因此,这完全取决于开发人员,并且提供了所有的灵活性。
出于展示的目的,在FastAdapter的示例应用程序中实现了这样一个案例。
您需要将一个ItemTouchHelper.SimpleCallback附加到RecyclerView,它将处理用户的滑动操作。
使用提供的util类,这是这样完成的:
touchCallback = new SimpleSwipeDragCallback(
this,
this,
leaveBehindDrawableLeft,
ItemTouchHelper.LEFT,
ContextCompat.getColor(this, R.color.md_red_900)
)
.withBackgroundSwipeRight(ContextCompat.getColor(this, R.color.md_blue_900))
.withLeaveBehindSwipeRight(leaveBehindDrawableRight);
touchHelper = new ItemTouchHelper(touchCallback); // Create ItemTouchHelper and pass with parameter the SimpleDragCallback
touchHelper.attachToRecyclerView(recyclerView); // Attach ItemTouchHelper to RecyclerView您可以在此处找到完整的示例源代码:https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/SwipeListActivity.java#L120
https://stackoverflow.com/questions/52757781
复制相似问题