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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:51:48+00:00 2026-06-05T16:51:48+00:00

I’m having trouble going from finding each view based on its actual id like

  • 0

I’m having trouble going from finding each view based on its actual id like this-

TextView updateText = (TextView)findViewById(R.id.courtText1);

to finding each view based on the current value of “i” in my loop, like this-

for(int i=1; i<3; i++){
    TextView updateText = (TextView)findViewById(R.id.courtText"i");
}

Here is the layout XML-

<TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp" >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:background="@drawable/row_background"
                android:clipToPadding="true"
                android:padding="5dp" android:onClick="goToDetail">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/courtText1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Moscone Rec Center"
                        android:textColor="#D8D8D8"
                        android:textSize="20dp" />

                    <TextView
                        android:id="@+id/updateText1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />

                    <TextView
                        android:id="@+id/timeText1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />

                </LinearLayout>

                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/ic_dialog_map" android:onClick="goToMap"/>

                <ImageButton
                    android:id="@+id/imageButton3"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@android:drawable/ic_menu_share" android:onClick="shareUpdate"/>

            </TableRow>

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:background="@drawable/row_background"
                android:clipToPadding="true"
                android:padding="5dp" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/courtText2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Joe Dimaggio"
                        android:textColor="#D8D8D8"
                        android:textSize="20dp" />

                    <TextView
                        android:id="@+id/updateText2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />

                    <TextView
                        android:id="@+id/timeText2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />
                </LinearLayout>
                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/ic_dialog_map" />

                <ImageButton
                    android:id="@+id/imageButton3"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@android:drawable/ic_menu_share" />
            </TableRow>

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:background="@drawable/row_background"
                android:padding="5dp" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView
                        android:id="@+id/courtText3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Brentwood Rec Center"
                        android:textColor="#D8D8D8"
                        android:textSize="20dp" />

                    <TextView
                        android:id="@+id/updateText3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />

                    <TextView
                        android:id="@+id/timeText3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />
                </LinearLayout>
                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@android:drawable/ic_dialog_map" />

                <ImageButton
                    android:id="@+id/imageButton3"
                    android:layout_width="50dp"
                    android:layout_height="50dp"
                    android:src="@android:drawable/ic_menu_share" />
            </TableRow>

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="2dp"
                android:background="@drawable/row_background"
                android:padding="5dp" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Can't find your court?"
                        android:textColor="#D8D8D8"
                        android:textSize="20dp" />
                     <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Let us know"
                        android:textColor="#D8D8D8"
                        android:textSize="15dp" />

                     <ImageButton
                         android:id="@+id/imageButton4"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         android:src="@android:drawable/ic_dialog_email" android:onClick="createSupportEmail"/>

                </LinearLayout>
            </TableRow>
        </TableLayout>

Any thoughts on how to find the value of each item with a loop?

  • 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-05T16:51:51+00:00Added an answer on June 5, 2026 at 4:51 pm

    Give your container (LinearLayout) an id, and iterate over its children.

    LinearLayout container = (LinearLayout) findViewById(R.id.whatever);
    TextView updateText;
    
    for (int i = 0; i < container.getChildCount(); i++) {
        updateText = (TextView) container.getChildAt(i);
        // Do something to `updateText`
    }
    

    Update: That’s the general idiom for this type of thing. I just looked more closely at your code, and if I understand what you’re trying to do in this case, you want to iterate over the table rows and do something to the specific TextArea of each row. If so, then instead of courtText1, courtText2, etc., you should get rid of the number. Have one courtText, one upateText, and one timeText per row. Then do something like this:

    TableLayout table = (TableLayout) findViewById(R.id.give_it_an_id);
    TextView courtText;
    
    // For each row
    for (int i = 0; i < table.getChildCount(); i++) {
        // Get the one `courtText` in this row
        courtText = table.getChildAt(i).findViewById(R.id.courtText);
        if (courtText != null) {
            // Do something to `courtText`
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.