【发布时间】:2014-03-16 11:27:35
【问题描述】:
如果用户单击,我想更改单选按钮的文本颜色。但是我可以更改背景颜色,但我不想要那个..任何人甚至可以告诉如何根据选择的正确或错误选择放置十字或正确的标志......? 这是我的主类代码..
final RadioButton Red = (RadioButton)findViewById(R.id.radioButton1);
//RadioButton Blue = (RadioButton)findViewById(R.id.radioButton2);
RadioButton Green = (RadioButton)findViewById(R.id.radioButton3);
Red.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
Red.setBackgroundColor(Color.RED);
}
}
});
Green.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
}
});
这是我的布局文件:
<RadioGroup
android:id="@+id/radiogroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton"
/>
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
【问题讨论】:
标签: android