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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:31:33+00:00 2026-05-24T08:31:33+00:00

I’ve arraylist of objects and i need to bind these list of objects to

  • 0

I’ve arraylist of objects and i need to bind these list of objects to TableLayout at runtime but i didn’t get any data into it, please check my code:

XML code:

<TableLayout android:background="#cfe1edFF" android:id="@+id/tl"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" >

  <TableRow>
    <TextView android:text="Symbol"
    android:layout_height="fill_parent" android:textColor="#104e8b"
        android:layout_width="wrap_content"
        android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile"/>
    <TextView android:text="A/c Type"
    android:layout_height="fill_parent" android:textColor="#104e8b"
        android:layout_width="wrap_content"
        android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
    </TextView>
    <TextView android:text="Position" android:textColor="#104e8b" android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:layout_weight="1" android:gravity="center" android:background="@drawable/shapefile">
    </TextView>
  </TableRow>

    <ScrollView>      
    <TableLayout android:id="@+id/score_table" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"> 
      <TableRow></TableRow>         
    </TableLayout>
  </ScrollView>     
</TableLayout>

so from above TableLayout “score_table” i’m trying to bind data from ArrayList of objects like:

Code to bind table layout using arryalist objects:

public void TableBinding(ArrayList<Position> posLst)
    {
        TableLayout tLayout=(TableLayout)findViewById(R.id.score_table);
        Position pos;
        for(int i=0;i<posLst.size();i++)
        {
            TableRow tr = new TableRow(this);
            tr.setId(100+i);
            pos=posLst.get(i);
            tr.setLayoutParams(new LayoutParams(
                       LayoutParams.FILL_PARENT,
                       LayoutParams.WRAP_CONTENT));


            TextView b = new TextView(this);
            b.setText(pos.Symbol); 
            tr.addView(b);
            //b.setId(200+i);

            TextView b1 = new TextView(this);
            b1.setText(pos.AcType);
            tr.addView(b1);
            //b1.setId(300+i);

            TextView b2 = new TextView(this);
            b2.setText(pos.Position);
            tr.addView(b2);
            //b2.setId(400+i);



            /* Add row to TableLayout. */
            tLayout.addView(tr,new TableLayout.LayoutParams(
                    LayoutParams.FILL_PARENT,
                    LayoutParams.WRAP_CONTENT));

        }

    }

But i didn’t get any data into it, i already checked that ArrayList getting data, please help me.

Thanks,
nag.

  • 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-24T08:31:34+00:00Added an answer on May 24, 2026 at 8:31 am

    You try this way :

     ArrayList<String> tablesName = new ArrayList<String>();
     TableLayout tl;
    
    public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    
       tl = (TableLayout) findViewById(R.id.tableLayout1);
    
        for (int i = 0; i < posLst.size(); i++) {
        TableRow tr = new TableRow(this);
        CheckBox ch = new CheckBox(this);
        ch.setId(i);
    
        TextView tv2 = new TextView(this);
        tr.addView(ch);
        createView(tr, tv2, tablesName.get(i));
        tl.addView(tr);
    }   
    
        public void createView(TableRow tr, TextView t, String viewdata) {
        t.setText(viewdata);
        t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        t.setTextColor(Color.DKGRAY);
        t.setPadding(20, 0, 0, 0);
        tr.setPadding(0, 1, 0, 1);
        tr.addView(t); 
    }
    
    • 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
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I want to construct a data frame in an Rcpp function, but when I
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT

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.