是否可以将项目拖到 RecyclerView 之外?
2022-09-01 21:25:56
当我将一个项目从另一个项目拖放到它上面时,我需要以某种方式通知。RecyclerView
RecyclerView
- 可能吗?
- 或者我应该使用经典的拖放框架?
RecyclerView
蓝色项目位于一个片段中,红色项目位于另一个片段中。RecyclerView
我也尝试过使用 ItemTouchHelper,但它是 ItemTouchHelper 的 onMove() 方法。在将 item 移出时不调用回调。RecyclerView
private class CustomItemTouchCallback extends Callback {
@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
return makeMovementFlags(UP|DOWN|START|END, 0);
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
android.util.Log.d(TAG, "Move item from:" + viewHolder.getAdapterPosition() + " to: " + target.getAdapterPosition());
return true;
}
@Override
public void onMoved(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, int fromPos, RecyclerView.ViewHolder target, int toPos, int x, int y) {
android.util.Log.d(TAG, "Moved item from:" + fromPos + " to: " + toPos + " x: " + x + " y: " + y);
super.onMoved(recyclerView, viewHolder, fromPos, target, toPos, x, y);
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
}
@Override
public boolean isLongPressDragEnabled() {
return true;
}
@Override
public boolean isItemViewSwipeEnabled() {
return false;
}
}
我也发现了这个问题,但它不能解决我的问题。