我有以下的回收视图代码,允许用户向右滑动(从视图中删除卡片并从SQLite数据库中删除数据),还允许用户移动标签以重新排列。它有效运行,我很高兴。
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
//awesome code when user grabs recycler card to reorder
}
@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
//awesome code to run when user drops card and completes reorder
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
//awesome code when swiping right to remove recycler card and delete SQLite data
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
现在,我想要添加向左滑动并执行与向右滑动不同的操作的能力。到目前为止,我找到的所有解决方案都需要重写我的代码。有没有建议可以在我的现有代码中添加向左滑动的功能?