Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android-如何将我的单选按钮重新初始化为默认值_Android_Radio Button - Fatal编程技术网

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

android-如何将我的单选按钮重新初始化为默认值,android,radio-button,Android,Radio Button,我有一个名为statusGroup的放射组,其中包含两个单选按钮,第一个名为statusDone,另一个名为statusNotDone 我在我的xml文件中设置了默认检查单选按钮statusNotDoneandroid:checked=“true”,我有重置按钮,我需要将单选按钮变量重新初始化为默认值 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://sch

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

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

 <?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>
        @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);