How do I format a double using Android view data bindings?
String.valueOf() is also an option:
android:text="@{String.valueOf(earthquake.magnitude)}"
I haven't yet looked at the binding expression language in the M SDK preview, so I might be jumping to conclusions, but if this calls through to the normal String.format()
method, then it requires a pattern. Have you tried this?
android:text='@{String.format("%.1f", earthquake.magnitude)}'