1

Is it possible to use TableRow like this:

That is array of TableRows. This must be inside table layout where table layout is nested inside linear layout.

TableRow[] tr = new TableRow[dimension];
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
gkn06
  • 95
  • 8

2 Answers2

2

Yes... this is abosutely possible in Android . TableRow is a class and you are trying to make an array of objects of a class .

Aparupa Ghoshal
  • 309
  • 2
  • 10
0

Yes Absolutely Possible. check this link & try this code.

public void init(){
TableLayout ll = (TableLayout) findViewById(R.id.displayLinear);


for (int i = 0; i <2; i++) {

    TableRow row= new TableRow(this);
    TableRow.LayoutParams lp = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT);
    row.setLayoutParams(lp);
    checkBox = new CheckBox(this);
    tv = new TextView(this);
    addBtn = new ImageButton(this);
    addBtn.setImageResource(R.drawable.add);
    minusBtn = new ImageButton(this);
    minusBtn.setImageResource(R.drawable.minus);
    qty = new TextView(this);
    checkBox.setText("hello");
    qty.setText("10");
    row.addView(checkBox);
    row.addView(minusBtn);
    row.addView(qty);
    row.addView(addBtn);
    ll.addView(row,i);
}}

Check Answer Posted by Fredigato in that link. Hope this helps.

Community
  • 1
  • 1
i.n.e.f
  • 1,773
  • 13
  • 22
  • is multidimensional possible – gkn06 Feb 21 '14 at 11:41
  • What does multidimensional means For TABLE LAYOUT having TABLE ROW? from above code you can add dynamic number of TABLEROW in TABLE LAYOUT but i am not getting multidimensional Word for TABLELAYOUT. – i.n.e.f Feb 21 '14 at 11:46