【发布时间】:2012-03-23 17:47:26
【问题描述】:
基本上我有一个带有两个单选按钮的 Radio Group,其中一个标记为 RUN,另一个标记为 PASS。 在此下方,我还有一个标记为“通过完成”的复选框
问题:如何在选择 RUN 单选按钮时禁用复选框(因此无法选择复选框)并在选择 PASS 单选按钮时启用它? 任何帮助构建某种类型的 IF 语句将不胜感激。
XML
<RadioGroup
android:id="@+id/runandpass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<RadioButton
android:id="@+id/radiobuttonrun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RUN" android:layout_weight="50"/>
<RadioButton
android:id="@+id/radiobuttonpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PASS"
android:layout_weight="50"/>
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="" />
<CheckBox
android:id="@+id/checkBoxcmpltpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pass Complete"
android:layout_weight="6"/>
</LinearLayout>
JAVA
package com.aces.acesfootballuk;
import android.app.Activity;
import android.os.Bundle;
public class CoachesPage extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.coachespage);
}
};
【问题讨论】:
-
请至少阅读基本的 Java 手册和一些 Android SDK
标签: java android android-layout