我正在使用数据绑定来使用三元语法在TextView上显示文本.
android:text="@{vm.value.firstValue != null ? vm.value.firstValue.toString() : @string/source1}"
This code displays @string/source1
upon first loading of a fragment before the vm.value
completely being loaded by network call. Then, it display vm.value.firstValue
when the network call succeeds. However, I want to display the @string/source1
only when network call fails.
I wonder if it is okay to display nothing(keep it empty) while waiting for the network call to be done successfully. then, populate TextView based on if a network call success or not. If this sounds okay, I would like to know how to acheive that using databinding.