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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:19:58+00:00 2026-06-14T15:19:58+00:00

I have some trouble to add columns to a table programmatically, maybe I look/search

  • 0

I have some trouble to add columns to a table programmatically, maybe I look/search for the wrong keywords, but can’t find a proper solution.

I got this code:

 ScrollView sv = new ScrollView(this);

         TableLayout ll=new TableLayout(this);
         HorizontalScrollView hsv = new HorizontalScrollView(this);
         TableRow tbrow=new TableRow(this);
         for(int i=0;i<mConnector.idArray.size();i++) {
             tbrow=new TableRow(this);         

                 TextView tv1=new TextView(this);
                 //String s1 = Integer.toString(i);
                 try {
                String insecticide = mConnector.insecticideArray.get(i);
                String wegedoornuis = mConnector.wegedoornluisArray.get(i);
                String dosering = mConnector.doseringArray.get(i);
                String prijs = mConnector.prijsArray.get(i);
                String bestuivers = mConnector.bestuiversArray.get(i);
                String roofvijanden = mConnector.roofvijandenArray.get(i);                    

               // String result = insecticide +" | "+wegedoornuis+" | "+dosering+" | "+prijs+" | "+bestuivers+" | "+roofvijanden;
               // int id = Integer.parseInt(s3);
                 tv1.setId(i);

                 tv1.setText(id);
                 tbrow.addView(tv1);
                 }catch(java.lang.IndexOutOfBoundsException e){

                 }

             ll.addView(tbrow);
         }
         hsv.addView(ll);
         sv.addView(hsv);
         setContentView(sv);

What I wanted is that every String (after try{) is getting his own column.
So like String result (what is now in comment signs). but then that I can adjust the columns width.

Hope you guys know what I mean, else I can always add an image to illustrate.
Edit
Made an image fast:

enter image description here

  • 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-14T15:19:59+00:00Added an answer on June 14, 2026 at 3:19 pm

    You can’t add Strings directly to the view, but you could use text views to do the same thing. I’ll show you an example that I did once, and let you figure out how to do it for your own use.

            TableRow row=new TableRow(this.getApplicationContext());
            TableLayout tlayout=new TableLayout(this.getApplicationContext());
    
            tlayout.setGravity(Gravity.CENTER);
            tlayout.setBackgroundResource(R.color.background);
    
            row=new TableRow(this);
    
            TextView text1=new TextView(this.getApplicationContext());
            TextView text2=new TextView(this.getApplicationContext());
            TextView text3=new TextView(this.getApplicationContext());
    
            text1.setText(R.string.name);
            row.addView(text1);
            text2.setText(R.string.level);
            row.addView(text2);
            text3.setText(R.string.score);
            row.addView(text3);
            tlayout.addView(row);
            for (i=0;i<10;i++)
            {
                row=new TableRow(this.getApplicationContext());
                text1=new TextView(this.getApplicationContext());
                text2=new TextView(this.getApplicationContext());
                text3=new TextView(this.getApplicationContext());
    
    
                text1.setText(high_score_name.get(i));
                row.addView(text1);
                text2.setText(""+high_score_level.get(i));
                row.addView(text2);
                text3.setText(""+high_score_score.get(i));
                row.addView(text3);
                tlayout.addView(row);
            }
    

    Essentially, high_scores_....get(i) returns a string. Something very similar should work for your purposes.

    The output will look something like this, continued down 10 rows.

    name1  score1  level1
    name2  score2  level2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some trouble when trying to update a table by looping cursor which
I have some trouble when I try to map object to int . My
I have some trouble with my trac installation (version 11.4). What should I do
I have some trouble with jquery ui-events: In my application, there are some sliders.
I have some trouble achieving adequate real-time performance from my application and wondering if
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
I'm have some trouble with the fulltext CONTAINS operator. Here's a quick script to
I am mlearning javascript and have some trouble creating an onject via prototype. I
I'm training with Azure environment and I have some trouble with the object CloudDriver
Good Morning, i have some Trouble with the Zend Framework and Zend_DB_Select, i want

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.