radzio/android-data-binding-recyclerview

Click handling for items within a row

maberer opened this issue · 1 comments

How can we detect, if a "firstName" or "lastName" is clicked?
So generally: How can we detect which item has been clicked within a row item?
This should consider CompositeItemBinder with different item types...

I am thinking about having

"firstNameClickHandler()"
"lastNameClickHandler()"

in the activity?

you could do this

Set this on the view you want to be clickable

android:onClick="firstNameClickHandler"
android:tag="@{user}" // the viewmodel variable

and then in your activity

public void firstNameClickHandler(View v) {
    UserViewModel userViewModel = (UserViewModel)v.getTag();
}