在RadioGroup中添加了幾個RadioButton,然後設置其中某一個默認是選中狀態的時候,
裏面的每一個RadioButton都需要設置一個id,不然會出現都可選中的情況
錯誤的寫法:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="rtsp"/>
</RadioGroup>
正確的寫法:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radio_http"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http"/>
<RadioButton
android:id="@+id/radio_rtsp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="rtsp"/>
</RadioGroup>