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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:39:02+00:00 2026-06-07T00:39:02+00:00

i have three lists with the same number of elements in each other, i

  • 0

i have three lists with the same number of elements in each other, i want to put first element of all lists in a tablerow, then second element of all lists in another tablerow,
the lists are :

competitoinsIDs = new LinkedList<String>();
                marks = new LinkedList<String>();
                numOfQuestions = new LinkedList<String>();

so i use this function:

private void addTextViews() {
        // TODO Auto-generated method stub
        TableLayout tbl=(TableLayout) findViewById(R.id.tlMarksTable);
        for(int ctr=0;ctr<marks.size();ctr++)
        {
        //Creating new tablerows and textviews
        TableRow row=new TableRow(this);
        TextView txt1=new TextView(this);
        TextView txt2=new TextView(this);
        TextView txt3=new TextView(this);
        //setting the text
        txt1.setText(competitoinsIDs.get(ctr));
        txt2.setText(marks.get(ctr));
        txt3.setText(numOfQuestions.get(ctr));
        //the textviews have to be added to the row created
        row.addView(txt1);
        row.addView(txt2);
        row.addView(txt3);
        tbl.addView(row);
        }
    }

and this is the layout xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableLayout
        android:id="@+id/tlMarksTable"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dip"
            android:weightSum="2" >

            <TextView
                android:id="@+id/tvMarksCompetitionID"
                android:layout_weight="1"
                android:text="Competition"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/tvMarksMarks"
                android:layout_weight="1"
                android:text="Marks"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/tvMarksQuestionsNum"
                android:layout_weight="1"
                android:text="Questions"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </TableRow>
    </TableLayout>

</FrameLayout>

what am i doing wrong please ?

  • 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-07T00:39:03+00:00Added an answer on June 7, 2026 at 12:39 am

    The problem is that you don’t set proper LayoutParams on the TableRows and TextView that you add to the layout:

    private void addTextViews() {
            TableLayout tbl=(TableLayout) findViewById(R.id.tlMarksTable);
            for(int ctr=0;ctr<marks.size();ctr++) {
                TableRow row=new TableRow(this);
                TableLayout.LayoutParams tlp = new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
                TextView txt1=new TextView(this);
                TableRow.LayoutParams text1lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); 
                TextView txt2=new TextView(this);
                TableRow.LayoutParams text2lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); 
                TextView txt3=new TextView(this);
                TableRow.LayoutParams text3lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); 
    
                txt1.setText(competitoinsIDs.get(ctr));
                txt1.setLayoutParams(text1lp);
                txt2.setText(marks.get(ctr));
                txt2.setLayoutParams(text2lp);
                txt3.setText(numOfQuestions.get(ctr));
                txt3.setLayoutParams(text3lp);
                row.addView(txt1);
                row.addView(txt2);
                row.addView(txt3);
                row.setLayoutParams(tlp);
                tbl.addView(row);
            }
    }
    

    This is assuming that your data lists aren’t empty.

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

Sidebar

Related Questions

I have these three lists with the same number of elements List<String>competitoinsIDs = new
I have two lists old and new , with the same number of elements.
I have three lists that I want to convert into one list. When I
I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list
I have a list of lists and want to replace all the occurrences of
I have three lists of lists, and I'm trying to write a generator function
Suppose I have three lists: list1 = a, c, d, r, t list2 =
So I currently have three unordered lists in my header. This is a single-page
I have three cascaded drop down lists. ddlIllnessType, ddlIllnessSubType and ddlInfectiousAgent Initially, only ddlIllnessType
I have approximately 5,000 matrices with the same number of rows and varying numbers

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.