在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>