Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error with default value in Databinding

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?

enter image description here

I know still we can use tools:text to check output in preview pane, but how to overcome this issue in Databinding with default?

like image 236
Ravi Avatar asked Aug 31 '16 05:08

Ravi


People also ask

Which is better ViewBinding and DataBinding?

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.

Can I use both DataBinding and ViewBinding?

Data binding includes everything that ViewBinding has, so it wasn't designed to work side by side with View binding.

How do I enable DataBinding in build gradle?

Activate the usage of data binding. Open your app/build. gradle file and activate the usage of data binding. apply plugin: 'com.


1 Answers

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}'
like image 194
yennsarah Avatar answered Sep 18 '22 13:09

yennsarah