RadioButton.clearCheck 抛出错误

RadioButton.clearCheck throwing an error

我有一个程序,当单击按钮时,单选按钮会更改文本。我还希望在按下按钮后取消选择所有单选按钮。我的 onClickListener 中有以下代码:

 b.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        PreviousScore = score;

            Score.setText(String.valueOf(action()));
            i++;
            question1();
            Button mRadioGroup = (Button) findViewById(R.id.radioGroup);
            mRadioGroup.clearCheck();

    }

我收到以下错误:"Cannot Resolve Method" on .clearCheck()。

我哪里错了?

"Cannot Resolve Method" on mRadioGroup.clearCheck();。因为 Button doesn’t have method clearCheck. But RadioGroupclearCheck 方法。

使用

RadioGroup mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup);
mRadioGroup.clearCheck();

代替

Button mRadioGroup = (Button) findViewById(R.id.radioGroup);
mRadioGroup.clearCheck();