标签:java color ext button checked text 作业 new span
显示效果:
java代码
genderGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
public void onCheckedChanged(RadioGroup group,int chackedId){
if (femalButton.getId() == chackedId){
System.out.println("female");
Toast.makeText(Activity9.this,"famle",Toast.LENGTH_SHORT).show();
}
else if(maleButton.getId() == chackedId){
System.out.println("male");
}
}
});
这个监听是用来显示男女的,其中男女是单选只能在其中选择一个,不能选择两个
swimBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
if (isChecked){
System.out.println("swim is checked");
}
else {
System.out.println("swim is unchecked");
}
}
});
runBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
if (isChecked){
System.out.println("run is checked");
}
else{
System.out.println("run is unchecked");
}
}
});
readBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
if (isChecked){
System.out.println("read is checked");
}
else{
System.out.println("read is unchecked");
}
}
});
这三个判断是用来判断你选择的哪一个!这三个可以多选,当你选着其中任意一个的时候都会打印出一句话如一下效果
标签:java color ext button checked text 作业 new span
原文地址:http://www.cnblogs.com/Silence213/p/5999825.html