android - Why does nothing appear when adding TableRow to TableLayout from code -


i creating tablelayout in xml:

<tablelayout     android:id="@+id/button_area"     android:layout_width="fill_parent"     android:layout_height="0px"     android:layout_weight="3"> 

and try add buttons rows (to replicate effect of "wrap panel" - little surprised android doesn't have this, nevermind):

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,             windowmanager.layoutparams.flag_fullscreen);     setcontentview(r.layout.activity_main);      tablelayout layout = (tablelayout) findviewbyid(r.id.button_area);      tablerow row = new tablerow(this);     row.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.wrap_content, tablerow.layoutparams.wrap_content));      (int = 0; != 12; i++) {         button b = new button(this);         b.settext("something");         b.setlayoutparams(new tablelayout.layoutparams(tablelayout.layoutparams.wrap_content, tablelayout.layoutparams.wrap_content));          row.addview(b);          if (i + 1 % 4 == 0) {             layout.addview(row);             row = new tablerow(this);         }     } } 

the result nothing - no null pointer exceptions, no failures of logs, unfortunately no buttons visible in tablelayout.

the statements inside if clause never executed.

    if (i + 1 % 4 == 0) {         layout.addview(row);         row = new tablerow(this);     } 

that why.

remove if , let buttons added freely without condition, , show up, check fault in if condition: + 1 % 4 == 0


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -