Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Responding to Presses
As icing on the RecyclerView cake, CriminalIntent should also respond to a press on these list items. In Chapter 13, you will launch the detail view for a Crime when the user presses that Crime in the list. For now, show a Toast when the user takes action on a Crime.
As you may have noticed, RecyclerView, while powerful and capable, has precious few real responsibilities. (May it be an example to us all.) The same goes here: Handling touch events is mostly up to you. If you need them, RecyclerView can forward along raw touch events. But most of the time this is not necessary.
Instead, you can handle them like you normally do: by setting an OnClickListener. Because you want the entire row to be clickable, set ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access