startSwipe
Starts swiping the provided ViewHolder. By default, ItemTouchHelper starts swiping a View when user swipes their finger (or mouse pointer) over the View. You can disable this behavior by overriding ItemTouchHelper.Callback
For this method to work:
- The provided ViewHolder must be a child of the RecyclerView to which this ItemTouchHelper is attached.
- ItemTouchHelper.Callback must have swiping enabled.
- There must be a previous touch event that was reported to the ItemTouchHelper through RecyclerView's ItemTouchListener mechanism. As long as no other ItemTouchListener grabs previous events, this should work as expected.
viewHolder.dragButton.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (MotionEvent.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
mItemTouchHelper.startSwipe(viewHolder);
}
return false;
}
});
Content copied to clipboard
Parameters
viewHolder
The ViewHolder to start swiping. It must be a direct child of RecyclerView.