I'm trying to bind the enabled
value of an ImageView
using data binding with an ObservableInt
in a ternary operator like this:
<variable
name="myInt"
type="android.databinding.ObservableInt"/>
...
<ImageView
...
android:enabled='@{myInt > 1 ? false : true}'
...
/>
It works exactly as expected.
But when I change the expression to
android:enabled='@{myInt < 1 ? false : true}'
It throws the following compilation error:
The value of attribute "android:enabled" associated with an element type "ImageView" must not contain the '<' character.
Why can I check if myInt
is larger than 1 but can't check if it's smaller than 1?
You need to escape characters for xml something like this:
android:enabled="@{myInt < 1 ? false : true}"