From the course: Android Development Essential Training: 2 User Interface Design

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use string resources with placeholders

Use string resources with placeholders - Android Tutorial

From the course: Android Development Essential Training: 2 User Interface Design

Start my 1-month free trial

Use string resources with placeholders

- [Instructor] We've already seen how we can define simple string resources using the string XML tag. But what if we need to display more complex information in our string? For instance, we may want to display the number of items that the user has selected. There are many ways that we could accomplish this. But what if we want to be able to support multiple languages of our app? We will want to use a string resource. This is a special variation of a string resource that contains formatting arguments. The percent d is how we indicate that we plan on having decimal values inserted at this location in our string. Percent d is just one of many placeholder options available to us. Percent s is another one used for string placeholders. And percent f is used for floating point numbers. You can even add additional formatting information, as you see here, to indicate that you want to limit the number of decimal places to only…

Contents