Skip to content Skip to sidebar Skip to footer

Radiobuttons Don't Properly Select/deselect In Dynamically Created Radiogroup

When I create a RadioGroup in an XML layout file everything's fine, but when I create it dynamically the RadioButtons don't deselect when another is selected: Here's the code: pub

Solution 1:

You need to set some sort of ID for your radio button, as such:

int idRadio =<some number>;
radioButtonView.setId(idRadio++);
radioButtonView2.setId(idRadio++);

Once they have distinct IDs, it should work. Just make sure the IDs don't collide with any existing graphical element, and is not zero (go to your "gen" folder and look at R.java for the other element IDs).

Solution 2:

Post a Comment for "Radiobuttons Don't Properly Select/deselect In Dynamically Created Radiogroup"