Cannot bind double with Android databinding
This syntax also works:
android:text='@={""+item.value}'
and it can be inverted by adding a String
setter:
public void setValue(String value) {
this.setValue(Double.valueOf(value));
}
However when I change the type to int the app builds with now issue.
Yes, but it will fail at runtime. setText(int)
expects a string resource ID, not an arbitrary int
.
Is there way to bind double?
android:text="@{Double.toString(BindedValue.value)}"
This is another option for converting objects to String
:
android:text="@{String.valueOf(BindedValue.value)}"