android - add TableRow (containing LinearLayout) to Table -



android - add TableRow (containing LinearLayout) to Table -

i have complicated table, create 1 row little more flexible adding button or text view, have next code adding tablerow table. trying set linearlayout tablerow programmatically, row not show when run it. i'd appreciated if can point problem is.

tablerow tr = new tablerow(this); tr.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); final checkbox checkbox = new checkbox(this); checkbox.setpadding(10, 5, 0, 0); checkbox.settextsize(typedvalue.complex_unit_px, 15); checkbox.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { string item_clicked_on = (string) ((textview) view).gettext(); toast.maketext(getapplicationcontext(), item_clicked_on, toast.length_short).show(); } }); textview tv = new textview(this); tv.settext(" " + count + ". " + baby.getname()); tv.settextsize(typedvalue.complex_unit_px, 14); tv.setpadding(10, 10, 0, 0); tv.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { string item_clicked_on = (string) ((textview) view).gettext(); toast.maketext(getapplicationcontext(), item_clicked_on, toast.length_short).show(); } }); checkbox.setlayoutparams(new layoutparams(linearlayout.layoutparams.wrap_content,linearlayout.layoutparams.wrap_content)); tv.setlayoutparams(new layoutparams(linearlayout.layoutparams.wrap_content,linearlayout.layoutparams.wrap_content)); linearlayout linearlayout = new linearlayout(tr.getcontext()); linearlayout.setlayoutparams(new linearlayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); linearlayout.setorientation(linearlayout.horizontal); linearlayout.addview(checkbox, new layoutparams(linearlayout.layoutparams.wrap_content,linearlayout.layoutparams.wrap_content)); linearlayout.addview(tv, new layoutparams(linearlayout.layoutparams.wrap_content,linearlayout.layoutparams.wrap_content)); tablerow.addview(linearlayout); table.addview(tr, new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));

i trying create xml.

<tablerow android:id="@+id/tablerow3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <linearlayout android:id="@+id/linearlayout2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <checkbox android:id="@+id/checkbox1" android:layout_width="wrap_content" android:layout_height="wrap_content"></checkbox> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="choice 1" android:textcolor="#ffffff"></textview> </linearlayout> </tablerow>

you adding linear layout tablerow .

tablerow.addview(linearlayout);

but adding table row tr table table

table.addview(tr, new tablelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));

i think have add together tablerow table. 1 time check it.

android

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -