Adding swipe and dismiss actions

It is unlikely that we would need swipe and dismiss behavior in this particular app, as the lists are short and there is little to be gained by allowing users to edit them. However, so that we can see how this important and useful function is applied, we will implement it here even though we won't be including it in the final design.

Swiping, as well as dragging and dropping, is largely managed by the ItemTouchHelper, which is a type of RecyclerView.ItemDecoration. The callbacks provided for this class allow us to detect item movement and direction and to intercept these actions and respond to them in code.

As you can see here, there are just a few steps to implementing swipe and dismiss behavior:

  1. Firstly, our list ...

Get Android Design Patterns and Best Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.