【发布时间】:2016-01-14 10:46:32
【问题描述】:
我的应用程序会自动填充一封电子邮件,其中包含用户通过表单输入的信息。当我尝试显示他们选择的索引时,它给了我
android.support.v7.widget.AppCompatRadioButton {2d57753c VFED..C. ...P..ID 705,0-903,96#7f0d0056 app:id/RejectRadio}
这是正确的 id 等,但我宁愿它只说“拒绝”,或者如果选择其他按钮只是“接受”。我该怎么做。
XML
<RadioGroup
android:id="@+id/radiochoice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/EditTextFeedbackBody"
android:orientation="horizontal">
<RadioButton
android:id="@+id/AcceptRadio"
android:layout_width="wrap_content"
android:layout_marginStart="50dp"
android:layout_height="wrap_content"
android:text="@string/acceptbutton" />
<RadioButton
android:id="@+id/RejectRadio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/rejectbutton"
android:layout_marginStart="115dp" />
</RadioGroup>
JAVA
int radioButtonID = radiochoice.getCheckedRadioButtonId();
View radioButton = radiochoice.findViewById(radioButtonID);
int index = radiochoice.indexOfChild(radioButton);
final RadioGroup ApproveorReject = (RadioGroup) findViewById(R.id.radiochoice);
fAnswer = ApproveorReject.getChildAt(index).toString();
【问题讨论】:
标签: java android xml radio-button android-radiogroup