Skip to content
Advertisement

Android Data Binding pass arguments to onClick method

Is it possible to pass custom arguments to onClick method using the Data Binding Library? I have my layout xml file where I need to use the onClickListener:

JavaScript

and I a have my click handler code here:

JavaScript

Is it possible to pass my CategoryViewModel object from xml to click handler?

Advertisement

Answer

You can use a lambda expressions and pass the view in as a parameter.

JavaScript

If you need the view, you can pass that as well with:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement