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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:59:26+00:00 2026-05-23T04:59:26+00:00

I am creating TableRows dynamically. And there are two types of content for these

  • 0

I am creating TableRows dynamically. And there are two types of content for these TableRows.
Some have 4 Views.
And some have 2 Views.

The problem is that TableRows with two, try to occupy the same space as the layout of which have four.
This is happening:

Img ThisTextViewHasThisSize

Img TV0 __________________TV1 TV2

…

    TableLayout tl = (TableLayout) findViewById(R.id.myTableLayout);

    for (int i = 0; i < array.length; i++) {

        TableRow tr = new TableRow(this);

        ImageButton button = new ImageButton(this);
        tr.addView(button);

        TextView tv0 = new TextView(this);
        tv0.setText(array[i].something0());

            if (another type of TableRow) {
            TextView tv1 = new TextView(this);
            TextView tv2 = new TextView(this);
            tv1.setText(array[i].something1());
            tv2.setText(array[i].something2());
            tr.addView(tv1);
            tr.addView(tv2);

        }
        tr.addView(tv0);

        tl.addView(tr);
    }

Someone can tell me how to let the TableRows layouts totally independent from each other?

  • 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-23T04:59:27+00:00Added an answer on May 23, 2026 at 4:59 am

    You can set the span of a view within the table by using TableRow.LayoutParams. Eg:

    TableRow tr = new TableRow(this);
    
    //all rows have this button
    ImageButton button = new ImageButton(this);
    tr.addView(button);
    
    TextView tv0 = new TextView(this);
    tv0.setText("hey");
    
    if (some condition == true) {
        TextView tv1 = new TextView(this);
        TextView tv2 = new TextView(this);
        tv1.setText("heay 2");
        tv2.setText("hey 3");
        tr.addView(tv0);
        tr.addView(tv1);
        tr.addView(tv2);
    }else {
        TableRow.LayoutParams trlp = new TableRow.LayoutParams();
        trlp.span = 3;
        tv.setLayoutParams(trlp);
        tr.addView(tv0);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page where I am dynamically creating an asp.net table. At some
I have a problem that sounds like this: I am creating a set of
I am creating a TableRow at runtime. The trouble I have is that I
I have a TableLayout with dynamically added TableRows depending on the size of a
I am dynamically creating a table of ImageButton, I would like to have setPressed
Hi i am developing android application. I that i have creating the dynamic table
I am creating rows dynamically in javascript.As the controls in all rows have same
This problem is similar to when creating alternate colour table-rows, only we are dealing
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.
Creating liquid layouts is an immense pain. Now, I totally understand that tables should

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.