Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding adapter with multiple arguments in Kotlin

To use multiple arguments for a data binding adapter the Java syntax is

@BindingAdapter(value={"arg1", "arg2"}, requireAll = false)

However this does not compile in Kotlin:

Error:(13, 37) Unexpected tokens (use ';' to separate expressions on the same line)

what's the correct syntax for multiple arguments in Kotlin?

like image 892
Francesc Avatar asked Mar 06 '17 22:03

Francesc


People also ask

What is binding adapter in Android Kotlin?

Binding adapters are responsible for making the appropriate framework calls to set values. One example is setting a property value like calling the setText() method. Another example is setting an event listener like calling the setOnClickListener() method.

Which code is correct to create custom adapters in data binding?

To create a custom binding adapter, you need to create an extension function of the view that will use the adapter. Then, you add the @BindingAdapter annotation. You have to indicate the name of the view attribute that will execute this adapter as a parameter in the annotation.


1 Answers

Or you can just simply do this

@BindingAdapter("arg1", "agr2", "agr3", "agr4", requireAll = false)

as pointed in Android Official Docs

like image 189
jeytoe Avatar answered Oct 02 '22 12:10

jeytoe