Anyone have any idea why a BindingAdapter is being...
# android
l
Anyone have any idea why a BindingAdapter is being recognized at compile time as available, but at runtime during view inflation, the adapter is not called? It's as if the Xml parser is just skipping right over those attributes
m
l
It's a standard Kotlin extension binding. Single argument extended off of View that sets a value on the view
Looks functionally identical to yours
My initial thought was that extending
View
rather than a subtype isnt allowed. But I have done so before...
m
Extending
View
should be fine. Anything unusual about the binding expression in the layout? For example, are you not matching on data types for the value?
l
I am not, is that a requirement? I thought you could pass primitives without a data type? The in xml line is:
app:pcuDefault="true"
m
Change that to
app:pcuDefault="@{true}"
and see if that works. It has to be a binding expression with the
@{}
syntax, as the data binding system ignores ordinary XML attributes. I have not tried a boolean constant as the binding expression, though.
w
make sure you set your lifecycle observer, too
on the binding
m
that only matters if you are binding a
LiveData
-- in this case, it's a constant
l
Ended up driving and not replying, but @Mark Murphy that both was the challenge and is indeed something you can do. Data binding is perfectly happy with constants passed in like that. Thank you for the help!
👍 1