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

  • Home
  • SEARCH
  • 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 8997061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:15+00:00 2026-06-15T23:50:15+00:00

Okay, I want to use one layout and change my strings programatically using the

  • 0

Okay, I want to use one layout and change my strings programatically using the strings.xml.

I have 40 questions and always 4 answers (they are static).

so my idea would be something like:

while i < 40:
 set question to question[i]
 on answer click: i++

How can I fetch the strings dynamically. I always used getResources().getText(R.string.example).

Can I just do something like:

String dynamic = "R.string.example" + i;
getResources().getText(dynamic)
  • 1 1 Answer
  • 0 Views
  • 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-06-15T23:50:16+00:00Added an answer on June 15, 2026 at 11:50 pm

    Maybe you could save the answers and the questions in an array in strings.xml (or somewhere else), or maybe some more arrays if you want that. So you can then load the array like you do now with getResources(), but with getStringArray
    And if you have an array, you can just dynamically get the right answer/question or whatever you want to do with it.

    In strings.xml (or another xml):

    <string-array name="months_array">
        <item>Jan</item>
        <item>Feb</item>
        <item>Mar</item>
        <item>Apr</item>
        <item>May</item>
        <item>Jun</item>
        <item>Jul</item>
        <item>Aug</item>
        <item>Sep</item>
        <item>Oct</item>
        <item>Nov</item>
        <item>Dec</item>
    </string-array>
    

    In your code:

    String[] months = getResources().getStringArray(R.string.months_array);
    

    Is this what you wanted ?

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

Sidebar

Related Questions

Okay, I have this program and I don't want more than one instance of
I just want to ask if is it okay that I use native PHP
Okay, I currently use an eggdrop IRC bot on my server. I want to
Okay, so I want to have a generic method that can read data from
Okay so I have an idea on how I want to serve and cache
Okay, so I have a UITableView that I want to apply themes to. I
Okay all, I have a form that I want users to fill out. When
Okay so here is my issue. My work uses SVN. I want to use
Okay I have 2 files. One file is data that is updated every 10
okay i have a tabbed view, so two view controllers. in one view controller

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.