在此方法中,选中所有 buttonCheckAnswer
后会显示rbs
。
public static void checkSelected() {
boolean check = true;
for (boolean radioChecked : checked) {
if(Boolean.TRUE != radioChecked){
check = false;
}
}
if (check)
buttonCheckAnswer.setVisibility(View.VISIBLE);
在检查第一个 else statement
后立即显示buttonCheckAnswer
的方法rb
是多少?
POST UPDATE
从现在起,buttonCheckAnswer
会在第一个rb
被选中后显示,我想再添加一个Key answer
"You haven't checked all answers"
到目前为止,我在MainActivity中有两个选项
buttonCheckAnswer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(checkAnswers())
intent.putExtra("KEY_ANSWER", true);
else
intent.putExtra("KEY_ANSWER", false);
startActivity(intent);
}
});
我已经为此添加MainActivity
此方法“你还没有检查所有答案”
private boolean allAnswersChecked() {
boolean answered = true;
for (boolean radioAnswer : isAnswered)
answered = answered && radioAnswer;
return answered;
}
以及AnswerActivity
TextView textViewDisplayResult = (TextView) findViewById(R.id.text_view_display_result);
textViewDisplayResult.setText(getIntent().getBooleanExtra("KEY_ANSWER", false)?R.string.Good_answer:R.string.Wrong_answer);
答案 0 :(得分:0)
试试这个:在for循环中使用b
break
答案 1 :(得分:0)
保持简单:
public static void checkSelected() {
for (boolean radioChecked : checked) {
if(true == radioChecked){
buttonCheckAnswer.setVisibility(View.VISIBLE);
break;
}
}
}