Behavior of a radio group when changing orientation

I hope someone can help me understand what happens with the Android radio and onCheckedChanged callbacks when the orientation changes.

I have a group of radio stations with three switches. The second button is defined as the default, setting the checked attribute to true. My xml for the radio group is as follows:

    <RadioGroup
        android:id="@+id/rgReportRange"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal" >

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

        <RadioButton
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="@string/Two" />

        <RadioButton
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Three" />
    </RadioGroup>

RadioGroup has onCheckedChangedListener. When the orientation changes, the onCheckedChangedListener is called differently based on which button is selected before the orientation changes.

If button1 is selected, I see one callback for the onCheckedChanged method with checkedID equal to button1.

If button 2 is selected, I do not see the callback of the onCheckedChanged method.

3, onCheckedChanged. ID, 2. IDID, 3.

. , .

+3
1

manifest.xml Activity < > tag:

<activity
            android:configChanges="keyboardHidden|orientation"></activity>

::)

-1

All Articles