Discussion:
Invalid LayoutParams supplied to android.widget.TableRow
Romain Guy
2008-04-17 15:13:02 UTC
Permalink
On your TableRow you must set new TableLayout.LayoutParams and on your
TextViews you must set new TableRow.LayoutParams. The rule is simple:
on a child, set the layout params of its parent.
Hi guys,
I'm tying to figure out with this problem: I would programmatically
TextView tv_name = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_name.setText(step_name);
TextView tv_done = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_done.setAlignment(Layout.Alignment.ALIGN_OPPOSITE);
tv_done.setText(done);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
tr.addView(tv_name);
tr.addView(tv_done);
tl.addView(tr);
I've tried everything, but nothings works! Thank you!
--
Romain Guy
www.curious-creature.org
Pzikit Bloo
2008-04-17 15:05:52 UTC
Permalink
Hi guys,
I'm tying to figure out with this problem: I would programmatically
add rows to my TableLayout; here's the code:

TextView tv_name = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_name.setText(step_name);

TextView tv_done = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_done.setAlignment(Layout.Alignment.ALIGN_OPPOSITE);
tv_done.setText(done);

TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));

tr.addView(tv_name);
tr.addView(tv_done);

tl.addView(tr);

I've tried everything, but nothings works! Thank you!
Pzikit Bloo
2008-04-17 15:20:27 UTC
Permalink
It's really simple! :) It works!
Thank you Romain!
Post by Romain Guy
On your TableRow you must set new TableLayout.LayoutParams and on your
on a child, set the layout params of its parent.
Hi guys,
I'm tying to figure out with this problem: I would programmatically
TextView tv_name = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_name.setText(step_name);
TextView tv_done = new TextView(this);
tv_name.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_done.setAlignment(Layout.Alignment.ALIGN_OPPOSITE);
tv_done.setText(done);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(
TableRow.LayoutParams.FILL_PARENT,
TableRow.LayoutParams.WRAP_CONTENT));
tr.addView(tv_name);
tr.addView(tv_done);
tl.addView(tr);
I've tried everything, but nothings works! Thank you!
--
Romain Guywww.curious-creature.org
Loading...