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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:56:13+00:00 2026-05-25T12:56:13+00:00

I am trying to programmatically add a row to a table which is defined

  • 0

I am trying to programmatically add a row to a table which is defined in XML (this row has internal table in it).

<TableLayout android:id="@+id/maintable"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:stretchColumns="*" xmlns:android="http://schemas.android.com/apk/res/android">
    <TableRow android:id="@+id/tabrow">
        <TableLayout android:id="@+id/tableLayout1"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            xmlns:android="http://schemas.android.com/apk/res/android">
            <TableRow>
                <TextView android:id="@+id/titlerow" android:layout_height="fill_parent" android:text="Hello world"
                    android:gravity="center" android:layout_width="fill_parent"
                    android:layout_weight="1" android:textSize="17sp"></TextView>
            </TableRow>
            <TableRow>
                <LinearLayout android:orientation="horizontal" 
                    android:layout_width="fill_parent" android:layout_height="fill_parent"
                    android:layout_weight="1">
                    <TextView android:text="@string/time1" android:id="@+id/time1" style="@style/timeview"></TextView>
                    <TextView android:text="@string/time2" style="@style/dayview"></TextView>
                    <TextView android:text="@string/time3" style="@style/dayview"></TextView>

                </LinearLayout>
            </TableRow>

        </TableLayout>

    </TableRow>

Now I want to just add this(tabrow) row many times in the table.

How can I do it ?

  • 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-05-25T12:56:14+00:00Added an answer on May 25, 2026 at 12:56 pm

    something like this should do:

    // get your table layout
    TableLayout tl = (TableLayout) findViewById(R.id.WhateverYoursIs);
    
    // Create new row
    TableRow tr = new TableRow(this);
    tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
    
    // Create textview
    TextView t = new TextView(this);
    //
    // configure your textview's and do this 2 more times  
    //
    
    t.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
    
    // add textview to row
    tr.addView(t);
    //
    // do this 2 more times  
    //
    
    // add row to table
    tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
    

    you just have to put the row-creation-stuff in a loop depending on how often you need it

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

Sidebar

Related Questions

I'm trying to add table rows programmatically following the code here /* Find Tablelayout
I'm trying to programmatically add an identity column to a table Employees. Not sure
I am trying to programmatically add a contact in Android. Here is my code:
I have an access table that I am trying to add fields programmatically using
I am trying to add rows in a TableLayout programmatically and I am following
In this following code I intend to programmatically add two labels in each row
I've got a UITableView which has been created programatically. I'm now trying to add
I am trying to add programmatically new row to my pList file on iPhone.
Trying to programmatically add options to a SELECT drop down in IE Windows Mobile.
I'm trying to programmatically add an Execute SQL task from within a script task

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.