在检查第一个radioButton后使buttonCheckAnswer可见

时间:2017-05-04 11:46:18

标签: java android

在此方法中,选中所有 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);

2 个答案:

答案 0 :(得分:0)

试试这个:在for循环中使用b

break

答案 1 :(得分:0)

保持简单:

public static void checkSelected() {
    for (boolean radioChecked : checked) {
        if(true == radioChecked){
            buttonCheckAnswer.setVisibility(View.VISIBLE);
            break;
        }
    }
}