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 7872215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:08:28+00:00 2026-06-03T02:08:28+00:00

I am trying to change the values of several TextView elements but iterating through

  • 0

I am trying to change the values of several TextView elements but iterating through an array list and adding these values. However I can’t seem to find a way to change the R.id value that is used each time. For example:

for (int i=0; i<arrayList.size(); i++)
{
    TextView t = (TextView) dialog.findViewById(R.id.value+(i));
    t.setText(arrayList.get(i));
}

Where the values are in the format animals_eng1,animals_eng2 etc..
Any help appreciated.

  • 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-03T02:08:30+00:00Added an answer on June 3, 2026 at 2:08 am

    Your best bet is to create an array containing the resource IDs of each text view and looping through them..

    ex.

    int[] textViewIds = new int[] { R.id.animals_eng1, R.id.animals_eng2, R.id.animals_eng3 }; 
    

    Then in your activity you can loop through them and set the values like you desire

    for (int i=0; i<arrayList.size(); i++)
    {
       ((TextView)findViewById(textViewIds[i])).setText(arrayList.get(i));
    }
    

    You’ll have to make sure your arrayList size is the same as the number of textview resource IDs you set or you’ll end up with an out of bounds exception when looping

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

Sidebar

Related Questions

I'm trying to create a 2D array to store some values that don't change
I'm trying to execute this function when a select list's (LevelId0) value change but
I'm trying to change some config file user settings values in my WPF application,
I'm trying to update/change contact ringtone using this code: ContentValues values = new ContentValues();
I am trying to do an iteration on pixels to change the RGBA values
I'm trying to use jQuery to change the value of button.kill . However I
Hello I'm trying to change several controls' property according to some environment variables and
I'm trying to change the value of a dojo tree to display the correct
I am trying to programmatically change a value of a wxRadioButton in a way
I'm trying to change the color of a UILabel depending on the .text value

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.