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:

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.
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.