views:

113

answers:

1

I have a TableLayout on one Android Activity UI. It has two columns. Now I need to add a new row, and put an EditText box in second column of that new row. And also, I want that EditText full fill the whole cell. I have some code like this:

TableRow tr = new TableRow(context);
EditText et = new EditText(context);
et.SetMaxLines(4);
etText.setLayoutParams(new TableRow.LayoutParams(1));  //set it to the second coloumn

tr.addView(et);

tl.addView(tr);   //tl is the tableLayout

It puts the EditText in the second column fine, but the EditText is too small. I tried to use etText.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); but that seems to disabled the TableRow.LayoutParams setting. I guess each control can only have one LayoutParamas setting. So, how to make the EditText as a 4 lines text editor and also make sure it is in the second column of that row?

Thanks.

A: 

Maybe something like:

TableRow.LayoutParams params = TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

params.column = 1;

etText.setLayoutParams(params);

Matt