首页 > 代码库 > 第四次作业

第四次作业

显示效果:

技术分享

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");
}
}
});
这三个判断是用来判断你选择的哪一个!这三个可以多选,当你选着其中任意一个的时候都会打印出一句话如一下效果

技术分享

第四次作业