Listing 9.25: "Detecting presses in CrimeHolder" does not work

#1

First of all, the onClick handler makes use of an mCrime member on CrimeHolder, that was never defined before. Doing so, and setting it in bindCrime is not a problem. (I’m sharing my code on Github, if you want to click to see.)

Edit: I figured out the reason of my second problem below a couple minutes after posting, but I could not find a way to delete my post, so here’s what was my problem: I forgot to call .show() on my Toast! (Fix.) That was so obvious and simple it hurts… Anyway, the first part above is still a valid concern. :slight_smile:

Then I setup my click listener as suggested by the book’s listing: implement the OnClickListener interface, on setOnclickListener(this) in the constructor, and implement the onClick() callback, and still, no click seems to register, as I’ve been unable to show any toast… Here is my code.

You’ll notice a few differences in my code, as I’m also playing with data binding while reading the book, but I don’t believe it makes any change.

Is there anything wrong with my code anyway?
Is this article (Recycler View Item Click Listener) the correct solution?