samedi 1 septembre 2018

How set a 'timer' before running body from if/else statement?

I want to set some kind of 'timer' before the if/else statement runs parts of it's body. In this case the edit1.setText("") and edit1.setBackgroundColor(Color.parseColor("#FFFFFFF")); Is there a way to do this.

Thanks in advance, have a nice day!

public void check1(View view) {
    uinput = edit1.getText().toString();
    if (uinput.equals(answerList[0])) {
        edit1.setBackgroundColor(Color.parseColor("#00FF00"));
        score++;
        score_view.setText(String.valueOf(score));

        // next question
        // TIMER HERE
        view1.setText(questionList[1]);
        edit1.setText("");
        edit1.setBackgroundColor(Color.parseColor("#FFFFFF"));
    } else {
        edit1.setBackgroundColor(Color.parseColor("#FF0000"));
        wrong++;
        wrong_view.setText(String.valueOf(wrong));

        // next question
        // TIMER HERE
        view1.setText(questionList[1]);
        edit1.setText("");
        edit1.setBackgroundColor(Color.parseColor("#FFFFFFF"));
    }
}

Aucun commentaire:

Enregistrer un commentaire