tags:

views:

38

answers:

1

is it possible to have a string value in string.xml of the sort " some string PLACEHOLDER1 some more string" so that the place holders can be assigned the value at run time.

+3  A: 

Yes, see the following from android devguide

If you need to format your strings using String.format(String, Object...), then you can do so by putting your format arguments in the string resource. For example, with the following resource:

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

In this example, the format string has two arguments: %1$s is a string and %2$d is a decimal number. You can format the string with arguements from your application like this:

Resources res = getResources();
String text = String.format(
    res.getString(R.string.welcome_messages),
    username, mailCount);
Megha Joshi