如果用户没有按任何东西,我的应用程序(大脑训练师与我的应用程序类似)会崩溃。我试图通过添加if语句来修复它并检查问题的数量,但这没有帮助。
任何人都知道我应该做什么/尝试?
public void playAgain (View view){ //after the timer is finished , and we call it also in oncrate fist play
score = 0;
numOfQuestions = 0;
timerTextView.setText("30s");
// resultTextView.setText("");
pointsTextView.setText("");
scoreTextView.setText("");
correctTextView.setVisibility(View.INVISIBLE);
wrongTextView.setVisibility(View.INVISIBLE);
resultTextView.setVisibility(View.INVISIBLE);
pointsTextView.setText("0/0");
playAgainButton.setVisibility(View.INVISIBLE);
menuButton.setVisibility(View.VISIBLE);
gridScore.setVisibility(View.INVISIBLE);
scoreTextView.setVisibility(View.INVISIBLE);
The if statement when timer finished:
public void onFinish() {
//resultTextView.setText("Your Score is: ");
resultTextView.setVisibility(View.VISIBLE);
if (numOfQuestions==0){
score=0;
scoreTextView.setText("0/0");
} else {
scoreTextView.setText(Integer.toString(score) + "/" + Integer.toString(numOfQuestions));
}
scoreTextView.setVisibility(View.VISIBLE);
gridScore.setVisibility(View.VISIBLE);
timerTextView.setText("0s");
playAgainButton.setVisibility(View.VISIBLE);
menuButton.setVisibility(View.VISIBLE);
resultGridLayout.setVisibility(View.VISIBLE);
playAgainButton.setVisibility(View.VISIBLE);
menuButton.setVisibility(View.VISIBLE);
correctTextView.setVisibility(View.INVISIBLE);
wrongTextView.setVisibility(View.INVISIBLE);