Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use string format arguments in Android layout xml file [duplicate]

Tags:

android

I have a string defined in my String.xml file that uses format arguments, i.e.:

<string name="myString">Hello %1$s.</string>

Is there a way to assign a value to the format argument in a layout xml file? I have something like:

<TextView android:text="@string/myString"/>

I know I can do it in java, but is there a way to do it here?

Thanks!

like image 579
Cheryl Simon Avatar asked Dec 17 '09 19:12

Cheryl Simon


1 Answers

No, there is no means of applying a value to the format from a layout file -- only in Java. Sorry!

UPDATE: You can now use data binding for this — see the duplicate question.

like image 171
CommonsWare Avatar answered Oct 08 '22 20:10

CommonsWare