I'd like to create lots of buttons with constant width and height on demand.
How do do the 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 and set its X,Y coords according to row and col
relativeLayer.add(button);
}
}
I didn't find a real way to add layouts with buttons on demand. I wanted to the above with TableLayout and add LinearLayouts to it as long as I have space for them, but I didn't find a way to do include without specifying all the LinearLayout-s in the XMLs. I'm also having a problem with the spacing in the screen width: my button has a constant height and width, since its oval. So I can't use layout_weight.