I’m developing a quiz and I can’t change my screen. What’s wrong with my code?

Asked

Viewed 42 times

0

public void botaoClick(View view) {

    Button botaoResposta = (Button) view;

    if (botaoResposta.equals(respostaCorreta)) {
        acertos = acertos + 1;
        pontos = pontos + 10;

        Intent intent = new Intent(QuizActivity.this, Questao.class);
        startActivity(intent);

        Toast.makeText(QuizActivity.this, "ESPETACULAR", Toast.LENGTH_SHORT).show();


    } else {

        Toast.makeText(QuizActivity.this, "QUE PENA,VOCÊ ERROU", Toast.LENGTH_SHORT).show();
        acertos = erros + 1;
        pontos = pontos + 0;
    }
}

}

  • could give more details ? what is the error/problem you are facing ?

  • When I test the code in the emulator the goal and change the screen by clicking on the button of some alternative, but only displays the message "WHAT A PITY YOU MISSED" and does not change the screen.

  • So it means that if is always giving false. This answerCorrects with the correct answer button object ? Probably the error is there

  • Thank you. I’ll check.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.