How to add buttons with for loops to a layer in Android -
i'd create lots of buttons constant width , height on demand.
how do following in android?
for(row =0; row*buttonsizey<otherbuttonycoardinate;row++){ addbuttonstorow(); } do{ row++; addbuttonstorow(); }while(stillneedtoaddbutton); void addbuttonstorow(){ for(col=0;col*buttonsizex<screenwidth;col++){ //instantiate button , set x,y coords according row , col relativelayer.add(button); } }
i didn't find real way add layouts buttons on demand. wanted above tablelayout , add linearlayouts long have space them, didn't find way include without specifying linearlayout-s in xmls. i'm having problem spacing in screen width: button has constant height , width, since oval. can't use layout_weight.
you can create , add buttons per demand specifications required. please check https://stackoverflow.com/a/7198409/1878148
Comments
Post a Comment