elwis
elwis

Reputation: 1405

android tablerow and columns in code

I'm trying to create a TableLayout with dynamically added rows and columns (from an array of obbjects). Since it's dynamic must I code(?)

All the examples I can find is doing it using xml layouts. The only ones out there that does it in code only adds a single view, like a button, which makes me believe its not doable, and I need two columns at least, where one of the will contain a view with an image and text.

Upvotes: 2

Views: 1862

Answers (1)

Jaiprakash Soni
Jaiprakash Soni

Reputation: 4112

Try to create table and row doing something like this

TableLayout t=new TableLayout(this);
TableRow tr=new TableRow(this);

and add row with table by

t.addView(tr);

similarly you can add other view (text, image view etc.) by using addView() function

Upvotes: 3

Related Questions