我有一个onSwiped()在向右滑动而不向左滑动时做了必要的事情,问题是它仍然滑动,我希望它能够"冻结"当向左滑动时。
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.START | ItemTouchHelper.END,
ItemTouchHelper.START | ItemTouchHelper.END) {
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
Log.d(TAG, "whats swiped " + viewHolder.getAdapterPosition() + " direction: " + direction + " arrayListCountyNames.get(viewHolder.getAdapterPosition())" + arrayListCountyNames.get(viewHolder.getAdapterPosition()));
if (direction==16) {//do something}
答案 0 :(得分:0)
创建ItemTouchHepler.RIGHT
时,您应该将ItemTouchHelper.SimpleCallback
作为第二个参数传递:
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.START | ItemTouchHelper.END,
ItemTouchHelper.RIGHT));