Its create dynamic button in a single row
final LinearLayout layoutshape = (LinearLayout) findViewById(R.id.linearshape);
a = new Button[10];
for (int i = 0; i < 10; i++) {
a[i] = new Button(this);
a[i].setText(""+i);
a[i].setId(i);
a[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
a[i].setBackgroundResource(R.drawable.background);
layoutshape.addView(a[i]);
}
but I wanna make this to be split in to three rows. Eg: If I've 30 buttons then its should be displayed in 10 button in 1st row then next 10 in second row and 10 in third row
o/p buttons as to be:
b1 b2 b3 b4 b5
b6 b7 b8 b9 b10
b11 b12 b13 b14 b15