Im using DataBinding Api for setting the views in android layouts. Here is my layout.
layout.xml
android:text= "@{@string/generic_name(user.name)}"
Just make string resource like this.
Hello %s
android:text="@{`Hello ` + user.name}"/>
String's concat methodandroid:text="@{user.firstName.concat(@string/space).concat(user.lastName)}"
Here space is an html entity which is placed inside strings.xml. Because XML does not accept Html entities or special characters directly. (Link Html Entities)
\u0020
String.format()android:text= "@{String.format(@string/hello, user.name)}"
you have to import String class in layout in this type.
android:text="@{@string/generic_name(user.firstName,user.lastName)}"
In this case put a string resource in strings.xml
%1$s, %2$s
There can be many other ways, choose one you need.