I am generating a RadioButton series by code and I have not been able to change the state when a RadioButton loses the status of checked. Currently when you checked one and checked another, both are checked.
what I'm trying to do is not to leave that state with something like this.
the way I'm creating RadioButton is this.
//Creo un LinearLayaout como contenedor de los radioButton
rl = (LinearLayout) view.findViewById(R.id.content_radioGroup);
// Initialize a new RadioGroup
radioGroup_edad = new RadioGroup(getContext());
radioGroup_edad.setOrientation(RadioGroup.HORIZONTAL);
//ciclo para crear los radiobutton
for(int i=0; i<6; i++) {
RadioButton radioButton = new RadioButton(getContext());
radioButton.setText("r " + i);
radioButton.setId(i);
radioButton.setButtonDrawable(R.color.transparent);
radioButton.setWidth(100);
radioButton.setTextSize(16);
radioButton.setTextColor(getResources().getColor(R.color.textColor));
radioButton.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
radioGroup_edad.addView(radioButton);
}
// Finally, add the RadioGroup to main layout
rl.addView(radioGroup_edad);
radioGroup_edad.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
//al activarse este evento obtengo el checkedId al cual le voy a poner el estado de check
RadioButton radiobutton = (RadioButton) view.findViewById(checkedId);
radiobutton.setTextSize(24);
radiobutton.setTextColor(getResources().getColor(R.color.textColorWhite));
}
});
Some idea of how I can achieve this.
Thanks for the help.