android recylcerView應用drag swipe
建立ItemTouchHelper
並設定
itemTouchHelper.attachToRecyclerView(recyclerView);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ItemTouchHelper itemTouchHelper1 = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback() { | |
@Override | |
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder viewHolder1) { | |
return false; | |
} | |
@Override | |
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int i) { | |
} | |
@Override | |
public void onSelectedChanged(@Nullable RecyclerView.ViewHolder viewHolder, int actionState) { | |
super.onSelectedChanged(viewHolder, actionState); | |
} | |
@Override | |
public void clearView(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { | |
super.clearView(recyclerView, viewHolder); | |
} | |
}); |
留言
張貼留言