Skip to content

Databinding

Weiyi Li edited this page Apr 4, 2020 · 1 revision

BindingAdapter

No need to create BindingAdapter for a setter. For example, var isLoading: Boolean, which jvm signature is setLoading(Boolean), allows to use app:loading="@{true}" directly in layout. Otherwise you will get a warning when building the library:

Binding adapter AK(View, Boolean) already exists for isLoading! Overriding View.Companion#setLoading with View#setLoading.

Error occurs if use app:isLoading :

Cannot find a setter for app:isLoading that accepts parameter type 'java.lang.Boolean'

No need to add app as the prefix in BindingAdapter, otherwise warning:

Application namespace for attribute app:xxx will be ignored.

Clone this wiki locally