How to set a EditText in a certain column of a TableLayout?

Posted by Nick on Stack Overflow See other posts from Stack Overflow or by Nick
Published on 2010-05-05T23:49:07Z Indexed on 2010/05/05 23:58 UTC
Read the original article Hit count: 216

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about tablelayout