我的android问答应用程序在android studio中不断崩溃

我的android问答应用程序在android studio中不断崩溃,android,performance,android-studio,background,countdowntimer,Android,Performance,Android Studio,Background,Countdowntimer,我正在开发一个测验应用程序,我遇到了一个我的倒计时程序,它在我分配给它的文本视图中不断显示随机值,选项按钮在单击后不会恢复为我分配给它的颜色。这里是我的代码 public void selectEasy(View view){ if (view.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){ view.setBackgroundResource(R.drawable.butto

我正在开发一个测验应用程序,我遇到了一个我的倒计时程序,它在我分配给它的文本视图中不断显示随机值,选项按钮在单击后不会恢复为我分配给它的颜色。这里是我的代码

public void selectEasy(View view){
    if (view.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){
        view.setBackgroundResource(R.drawable.button_right);
        score++;

    } else{

        view.setBackgroundResource(R.drawable.button_wrong);

        if (button0.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){
            button0.setBackgroundResource(R.drawable.button_right);
        }else if (button1.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){
            button1.setBackgroundResource(R.drawable.button_right);
        }else if (button2.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){
            button2.setBackgroundResource(R.drawable.button_right);
        }else if (button3.getTag().toString().equals(Integer.toString(locationOfCorrectAnswer))){
            button3.setBackgroundResource(R.drawable.button_right);
        }
    }
    GenerateQuestion();
}
随机问题生成的第二种方法

public void GenerateQuestion(){


    question++;
    Easy_score.setText(Integer.toString(score));
    Easy_question.setText(Integer.toString(question) + "/"+ 10);
    Easy_time.setText(10 + "s");
    button0.setBackgroundResource(R.drawable.button_style);
    button1.setBackgroundResource(R.drawable.button_style);
    button2.setBackgroundResource(R.drawable.button_style);
    button3.setBackgroundResource(R.drawable.button_style);

    new CountDownTimer(10100, 1000){
        @Override
        public void onTick(long millinseconds) {
            Easy_time.setText(String.valueOf(millinseconds / 1000) + "s");
        }

        @Override
        public void onFinish() {

            GenerateQuestion();
        }
    }.start();

    int[] picture = {};

    String[] incorrectOption = {};


    Random random = new Random();

    displayPicture = random.nextInt(21);

    display.setImageResource(picture[displayPicture]);

    answers.clear();

    locationOfCorrectAnswer = random.nextInt(4);

    for (int i = 0; i < 4; i++){

        if (i == locationOfCorrectAnswer){

            answers.add(getResources().getResourceEntryName(picture[displayPicture]));

        } else {

            LocationOfWrongAnswer = random.nextInt(36);

            while (LocationOfWrongAnswer == displayPicture) {
                LocationOfWrongAnswer = random.nextInt(36);
            }

            answers.add(incorrectOption[LocationOfWrongAnswer]);

        }


    }

    button0.setText(" A. " + answers.get(0).substring(4).replace("_"," ").replace("1", "-"));
    button1.setText(" B. " + answers.get(1).substring(4).replace("_"," ").replace("1", "-"));
    button2.setText(" C. " + answers.get(2).substring(4).replace("_"," ").replace("1", "-"));
    button3.setText(" D. " + answers.get(3).substring(4).replace("_"," ").replace("1", "-"));

}
public void GenerateQuestion(){
问题++;
Easy_score.setText(Integer.toString(score));
Easy_question.setText(Integer.toString(问题)+“/”+10);
简易时间设置文本(10+“s”);
按钮0.setBackgroundResource(R.drawable.button_样式);
button1.setBackgroundResource(R.可绘制.button_样式);
按钮2.设置背景资源(R.可绘制的按钮样式);
按钮3.收进背景资源(R.可绘制。按钮样式);
新的倒计时(101001000){
@凌驾
公共void onTick(长毫秒){
Easy_time.setText(String.valueOf(毫秒/1000)+“s”);
}
@凌驾
公共无效onFinish(){
GenerateQuestion();
}
}.start();
int[]图片={};
字符串[]不正确选项={};
随机=新随机();
displayPicture=random.nextInt(21);
display.setImageResource(picture[displayPicture]);
答案:clear();
正确答案的位置=random.nextInt(4);
对于(int i=0;i<4;i++){
if(i==正确答案的位置){
add(getResources().getResourceEntryName(图片[displayPicture]);
}否则{
LocationOfWingAnswer=random.nextInt(36);
while(locationOfWingAnswer==displayPicture){
LocationOfWingAnswer=random.nextInt(36);
}
答案。添加(不正确选项[LocationOfWingAnswer]);
}
}
按钮0.setText(“A.”+答案.get(0).子字符串(4).替换(““,”).replace(“1”,“-”));
按钮1.setText(“B.”+answers.get(1).子字符串(4).替换(““,”).replace(“1”,“-”));
按钮2.setText(“C.”+答案.get(2).子字符串(4).替换(““,”).replace(“1”,“-”));
按钮3.setText(“D.”+答案.get(3).子字符串(4).替换(““,”).replace(“1”,“-”));
}

当单击按钮时,倒计时计时器显示随机值,并且按钮不会恢复为初始颜色

如果出现故障,经验法则是发布此故障请我希望倒计时计时器停止显示随机值问题标题不正确