android - 如何将我的单选按钮重新初始化为默认值

android - how to reinitialize my radio button to default

我有一个名为 statusGroup 的 RadioGroup,其中包含两个单选按钮,第一个名为 statusDone,另一个名为 statusNotDone

我在我的 xml 文件 android:checked="true" 中将默认检查单选按钮设置为 statusNotDone,我有重置按钮,我需要将我的单选按钮变量重新初始化为默认值。

 <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

        <RadioGroup
            android:id="@+id/statusGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/status"
            android:orientation="horizontal"
            android:layout_marginTop="12dp" >

            <RadioButton
                android:id="@+id/statusDone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/done_string" />

            <RadioButton
                android:id="@+id/statusNotDone"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="@string/not_done_string" />
        </RadioGroup>

    </RelativeLayout>

我的 java 文件

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.add_todo);

    mDefaultStatusButton = (RadioButton) findViewById(R.id.statusNotDone);
            mDefaultPriorityButton = (RadioButton) findViewById(R.id.medPriority);
            mPriorityRadioGroup = (RadioGroup) findViewById(R.id.priorityGroup);
            mStatusRadioGroup = (RadioGroup) findViewById(R.id.statusGroup);

    }


    // TODO - Set up OnClickListener for the Reset Button
            final Button resetButton = (Button) findViewById(R.id.resetButton);
            resetButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.i(TAG, "Entered resetButton.OnClickListener.onClick()");

                    // TODO - Reset data to default values
                    mTitleText.setText("");

                    // how to reinitialize  to the default radio buttons 

                    // reset date and time
                    setDefaultDateTime();
                }
            });
   // Please clear radio group using clearCheck() function
   // Check default radio button using check() function 

    statusGroup.clearCheck();
    statusGroup.check(R.id.statusNotDone);