Concat Two Strings In TextView Using DataBinding
Sometimes we might need a functionality where we needs to concat two strings in xml only. So here are the different ways of how can we do it using databinding.
1. Using grave accent(`)
1 |
android:text="@{`Hello ` + user.firstName}" |
2. Using strings.xml
1 |
android:text="@{@string/location(user.city,user.state)}" |
and in your string.xml file
1 |
<string name="location">%1$s, %2$s</string> |