Question

I have programmatically created GridLayout 3x3.

I need to fill it with 5 RadioButtons, like this:

   0 1 2
 0 O   O
 1   O
 2 O   O

But in my app I have this:

   0 1 2
 0 O   
 1   O
 2     O

Here is the code I use to create Buttons:

Spec FieldRowParam = GridLayout.spec(FieldRow);
Spec FieldColumnParam = GridLayout.spec(FieldColumn);
GridLayout.LayoutParams Params = new GridLayout.LayoutParams(FieldRowParam, FieldColumnParam);
btnNew = new RadioButton(this); 
FieldLayout.addView(btnNew,Params);

Coordinates I use in int FieldRow and int FieldColumn:

0-0; 1-1; 2-2; 0-2; 2-0.

Buttons with 0-0 and 0-2 coordinates merged into 1 button, 2-2 and 2-0 buttons too.

I think the problem in empty cells between buttons, but i can't solve it. Thanks for your answers!

Was it helpful?

Solution

just add RadioButton in all places and set visibility invisible when you don't need RadioButton

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top