Android RadioButton class three kinds of checked way

The first : main.xml file,RadioButton element add android:checked attribute, set "true";

The second : use setChecked() on the RadioButton from within your onCreate() callback in your activity.example:

    RadioButton rb = (RadioButton)findViewById(R.id.radio1);

    rb.setChecked(true);

The third:use check() on the RadioGroup from within your onCreate() callback in your activity.example:

    RadioGroup rg = (RadioGroup)findViewById(R.id.radiogroup);

    rg.check(R.id.radio2);

你可能感兴趣的:(android,File,Class,callback,RadioButton)