我有一个收音机组,有2个选项,分别是男性和女性。 我想将RadioButton Male保存为int数字“1”,女性保存为我的数据库中的“2”。 但我真的不知道如何实现它。 如果有人可以在这个问题上启发我吗? 预先感谢您。如何将单选按钮文本更改为int?
<RadioGroup
android:id="@+id/radio_sex"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/email_address"
android:layout_alignTop="@+id/textView5"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radio_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male" />
<RadioButton
android:id="@+id/radio_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
你有没有考虑取的单选按钮的索引你RadioGroup中?如果没有,也许你需要看到这个[问题](http://stackoverflow.com/questions/6440259/how-to-get-the-selected-index-of-a-radiogroup-in-android)。 –
感谢Lokesh Mehra,我在这个问题中得到了一些非常有用的信息。 –