friends. I have a very silly problem with a radio group. However, I cannot find a solution.
I will try to describe how to reproduce my problem: I have a radio group and two buttons inside. I choose one of them, say the 1st. Then I clear the selection by calling radioGroup.clearCheck () After I try to select the 1st button, but don't check it. If I check 2nd, it is checked normally. If I check 1st after checking 2nd, it also works fine.
It may seem crazy, but 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 = ""; }
to clean them
Orest
source share