What is the recommended way to setup multiple click listeners for buttons within a single RecyclerView row?
g
gildor
01/17/2021, 6:00 AM
This is not related to Kotlin, please check channel's description
👍 1
☝️ 1
j
jefbit
01/17/2021, 6:01 AM
You can pass them through the recyclerview constructor using lambda parameters and have your activity or fragment handle the click event
👍 1
j
Joshy Josh
01/17/2021, 6:04 AM
Thanks, I'll try that route. Also, sorry for going off topic.
s
sbeve
01/17/2021, 7:13 AM
multiple click listeners for the same button? or one click listener for each button in a view holder? The best appraoch imo is to use an interface. define an interface which contains all methods which act as click listeners without. implement the interface in your activity or fragment and implement each of the methods in your activity or fragment. Pass in the activity or fragment to the contractor of your adapter.
a
am414
01/17/2021, 10:02 AM
send an id (like when u send a position)to distinguished the buttons
j
Joshy Josh
01/17/2021, 6:31 PM
Yeah, so basically each item row would have several buttons, three currently, that do different things. One would be to delete that item, one to copy, and another to make a textview on that row visible, like a password field.