Redeem Now
Read More
Read now

String Placeholders or Formatting strings in android


In this blog,

we will get interact with the string placeholder. And see, is it possible to Concatenate multiple strings in XML?
How to reference one string from another string in strings.xml?


What we can’t do

If we want to Concatenate multiple strings in XML? or reference one string from another string in strings.xml? so what we can’t do with the strings,

Because here it will search for a String with reference @string/music Pop which does not exist.

So what we can do to want string placeholders which can be change dynamically.

What We can do, the “String Formatting”

“Formatting strings”, 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:

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 arguments from your application like this:

So what can we do with music string,

in java file,


output: Rock Music

output: Pop Music





. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again