As onItemClick
is no more in RecyclerView
, does ButterKnife still able to handle its item clicks with @onItemClick
or with @onClick
annotations?
If not so, any work around to use that?
Where do you add the android:onClick attribute to make items in a RecyclerView respond to clicks? In the layout file that displays the RecyclerView, add it to the element. Add it to the layout file for an item in the row.
onCreateViewHolder(parent: ViewGroup, viewType: Int) Parent is the ViewGroup into which the new View will be added after it is bound to an adapter position and viewType is the type of the new View. This method will return a new ViewHolder that holds a View of the given view type.
My solution is to use @OnClick
inside the ViewHolder. This is the only way to have a clue about which element of the "list item" has been clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With