friends. I'm having a really silly problem with radiogroup. Yet I'm unable to find solution.
I will try to describe how to reproduce my problem: I have radiobutton group and two buttons inside. I select one of them, lets say 1st one. Then I'm clearing selection by calling radioGroup.clearCheck() After I'm trying to select 1st button, but its not checking. If I check 2nd, it checks normally. If I check 1st after checking 2nd it also works normally.
This may sound crazy, yet I can't fix it. Please help me, thanks in advance.
I use
@Override
protected void init() {
View view = View
.inflate(getContext(), R.layout.wo_task_yn_result, null);
performed = (RadioButton) view.findViewById(R.id.yn_yes);
notPerformed = (RadioButton) view.findViewById(R.id.yn_no);
radioGroup = (RadioGroup) view.findViewById(R.id.yn_options);
performed.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView,
final boolean isChecked) {
Log.d(YES, "verify");
if (isChecked) {
Log.d(YES, "checked");
result = YES;
}
}
});
notPerformed.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView,
final boolean isChecked) {
Log.d(NO, "verify");
if (isChecked) {
Log.d(NO, "checked");
result = NO;
}
}
});
addView(view);
}
To create buttons and
@Override
public void clear() {
radioGroup.clearCheck();
result = "";
}
for clearing them
I had the same problem. Was unable to select the first radioButton in the group, but could select the other two. And after selecting the second radioButton, I could select the first one as well. I resolved it by doing a single radioGroup.clearCheck() instead of individual radioButtonA.setChecked(false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With