Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1053753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:18:06+00:00 2026-05-16T17:18:06+00:00

Is it possible to have placeholders in string values in string.xml that can be

  • 0

Is it possible to have placeholders in string values in string.xml that can be assigned values at run time?

Example:

some string PLACEHOLDER1 some more string

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:18:07+00:00Added an answer on May 16, 2026 at 5:18 pm

    Formatting and Styling

    Yes, see the following from String Resources: Formatting and Styling

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

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

    Basic Usage

    Note that getString has an overload that uses the string as a format string:

    String text = res.getString(R.string.welcome_messages, username, mailCount);
    

    Plurals

    If you need to handle plurals, use this:

    <plurals name="welcome_messages">
        <item quantity="one">Hello, %1$s! You have a new message.</item>
        <item quantity="other">Hello, %1$s! You have %2$d new messages.</item>
    </plurals>
    

    The first mailCount param is used to decide which format to use (single or plural), the other params are your substitutions:

    Resources res = getResources();
    String text = res.getQuantityString(R.plurals.welcome_messages, mailCount, username, mailCount);
    

    See String Resources: Plurals for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have horizontal lists that can run as wide as possible but
Is it possible to manipulate the placeholders so that I can not only set
I'd like to have placeholders in an .swf file that I can populate with
Is it possible to have a free iPhone app that has say an initial
I have a String that I'm autowiring as a bean. The value for the
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
How could I customize placeholders in my .rst file with actual values? For example,
I'm writing some JavaScript to implement placeholder text in browsers that don't have it.
I have a form that has placeholders for input fields. It uses html5 placeholder
We have a solution with multiple web projects, and there are some pages that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.