我在使用Java中的复选框时遇到问题。无论复选框是否被选中,结果始终为“是”。请有人帮我检查一下下面的代码是否有错误?复选框显示相同的结果,无论它是否被检查
private String whippedCreamMethod(){
CheckBox checkBoxWhippedCream = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
if (checkBoxWhippedCream.isSelected()){
whippedCream = "No";
} else {
whippedCream = "Yes";
}
return whippedCream;
}
看看这个帖子:[复选框的Java(https://stackoverflow.com/questions/27423485/java-check-if-checkbox-is-checked) – etienne31