0
我目前有一个布局,如果用户按下选项1按钮,将设置一个新布局,其右侧的单选按钮被选中。然后“检查器”按钮获得一个新的onClick值。如何在java代码中更改此选项,以便option1clicked方法将第一个单选按钮选中值设置为“true”。关于单选按钮的选中状态
此外,我做了这些之后,我该如何做到这一点,当我点击按钮时,系统会检查是否检查了单选按钮?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Checker"
android:onClicked="nobuttonpressed" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:text="Option 1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:onClick="option1clicked" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:checked="false"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:text="Option 2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:onClick="option2clicked" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:checked="false"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
请解释更好您的问题。这很难理解。 –