As described in Databinding document we can use default
to check value in preview pane.
It is working perfectly if i have simple String like below :
android:text="@{place, default=Columbia}"
But i have combination of state and country and if i am using ,(comma) then it is creating problem.
android:text="@{place, default=Gujarat, IN}"
It is showing error , unexpected
, How to resolve it?
I know still we can use tools:text
to check output in preview pane, but how to overcome this issue in Databinding
with default
?
ViewBinding vs DataBindingThe main advantages of viewbinding are speed and efficiency. It has a shorter build time because it avoids the overhead and performance issues associated with DataBinding due to annotation processors affecting DataBinding's build time.
Data binding includes everything that ViewBinding has, so it wasn't designed to work side by side with View binding.
Activate the usage of data binding. Open your app/build. gradle file and activate the usage of data binding. apply plugin: 'com.
Changing the ticks will work, but it'll show the ticks:
android:text='@{place, default="Gujarat, IN"}'
What you can do, is to create a string resource:
<string name="placeholder">Placeholder, text</string>
And use it as default value:
android:text='@{viewModel.placeHolder, default=@string/placeholder}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With