Closed DenisMondon closed 8 years ago
@DenisMondon Handling click events is not covered by this library as its primary aim was to add simple support for swiping list items. You should refer to other resources on the web for this instead (such as http://www.littlerobots.nl/blog/Handle-Android-RecyclerView-Clicks/).
Seeing how difficult this has become though, I might consider adding a callback for this similiar to the onSwipe()
callback in the future.
@TR4Android Thanks for the answer :) I will read this article :) And I think it could be a good feature like onSwipe()!! ;)
Thanks!
@DenisMondon Sure :smiley: Like I said, I will look into adding this in the future, for now you'll have to implement click handling yourself though.
The article works with my "normal" Adapter (without swipe), but not with yours (SwipeAdapter). For me, the only code that changes is:
return new ViewHolder(layoutInflater.inflate(R.layout.my_layout, parent, false);
Your code uses true (for the attachToRoot parameter).
Do you have any ideas?
@DenisMondon I'll look into this and add support for item clicks as soon as I can! Bear with me.
@DenisMondon What excactly does not work? Is the click never registered or is there an exception?
The click is never registered...
@DenisMondon You could try setting your click listener to a specific View
(using an id). Does that work?
@DenisMondon I decided against this as it's pretty simple to implement actually. I did however update the sample code to reflect this and added click listener to the items there (see commit 0ad6e5d147e608e29db14d0b9ddfb42a28fbe9ee and the updated SampleAdapter
and item_sample
)
I'm closing this in favor of developers own implementations. If you have any trouble getting the sample code to work for you, you can still ask for help here.
Hi,
Nice library! I was wondering how to implement an OnItemClickListener for each item. Do you have any ideas?
Thanks. Denis