Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Java应用程序正在冻结,没有返回错误消息_Java_Android - Fatal编程技术网

Android Java应用程序正在冻结,没有返回错误消息

Android Java应用程序正在冻结,没有返回错误消息,java,android,Java,Android,由于某种原因,当我按下某个按钮时,我的Android Java应用程序冻结了。然而,应用程序似乎没有崩溃,因为没有错误消息发送回Android Studio。它只是冻结,一段时间后,应用程序将重新启动 下面是在ButtonClick上执行的代码。我知道这非常令人困惑,因为我使用了太多的变量:/I我将尝试在实际按钮代码上方添加一些声明 ChronometerList = new Chronometer[]{Overtime1,Overtime2,Overtime3,Overtime4,Overti

由于某种原因,当我按下某个按钮时,我的Android Java应用程序冻结了。然而,应用程序似乎没有崩溃,因为没有错误消息发送回Android Studio。它只是冻结,一段时间后,应用程序将重新启动

下面是在ButtonClick上执行的代码。我知道这非常令人困惑,因为我使用了太多的变量:/I我将尝试在实际按钮代码上方添加一些声明

ChronometerList = new Chronometer[]{Overtime1,Overtime2,Overtime3,Overtime4,Overtime5,Overtime6,Overtime7,Overtime8,Overtime9,Overtime10,Overtime11,Overtime12};
 //is an Array of Chronometers

    TimeList = new TextView[]{ TimeUntilTopic1Ends,TimeUntilTopic2Ends,TimeUntilTopic3Ends,TimeUntilTopic4Ends,TimeUntilTopic5Ends,TimeUntilTopic6Ends,TimeUntilTopic7Ends,TimeUntilTopic8Ends,TimeUntilTopic9Ends,TimeUntilTopic10Ends,TimeUntilTopic11Ends,TimeUntilTopic12Ends}; 
    // Array of Textviews, that show us the Time Left, i need so many since i build a table out of lines and every line needs a timer

    TopicTimer = new MyCounter[]{TopicTimer1,TopicTimer2,TopicTimer3,TopicTimer4,TopicTimer5,TopicTimer6,TopicTimer7,TopicTimer8,TopicTimer9,TopicTimer10,TopicTimer11,TopicTimer12};
//MyCounter通过倒计时->简单类进行扩展 //所有计时器都在正常构建中,没有错误

这是代码。Hella很困惑,但我希望你能帮助我

  NextTopic.setOnClickListener(new OnClickListener() {

       @Override
       public void onClick(View v) {
        // TODO For some Reason this freezes the Whole Program
           if(TimeList[row-1].getText().toString() == "Done")
           {
               ChronometerList[row-1].stop();
               long ElapsedTimeInMillis = SystemClock.elapsedRealtime() - ChronometerList[row-1].getBase();
               int RowUsed = 0;
               int n = 0;
               while(TimeList[row].getText()!= "null")
               {
                    RowUsed++;
               }

              if(RowUsed != 0) {
                  int ElapsedTime = (int) (long) ElapsedTimeInMillis;
                  double SubtractionTime = ElapsedTime / RowUsed;

                  while (RowUsed >= n) {
                      TimeList[row + n].setText(String.valueOf(Double.parseDouble(TimeList[row + n].getText().toString()) - SubtractionTime));
                      n++;
                  }
                  row++;
                  TopicTimer[row-1].start();
              }
              else
              {
                //nothing yet

              }


           }
           else
           {


               int RowsLeft = 0;
               int n = 0;
               while(TimeList[row].getText()!= null)
               {
                   RowsLeft++;
               }
            // have to split up the text in there cause there are **m **s in it and not just the number
            String TimeOutput = TimeList[row - 1].getText().toString();
            String[] TimePartSeconds = TimeOutput.split("m ");
            String Minutes = TimePartSeconds[0];
            String SecondsLetters = TimePartSeconds[1];
            String[] GetSeconds = SecondsLetters.split("s");
               String seconds = GetSeconds[0];


            int SecondsLeft = (Integer.valueOf(Minutes)*60) +(Integer.valueOf(seconds));
            long AdditionTimeSeconds = SecondsLeft/RowsLeft;

            TopicTimer[row-1].onFinish();


            while (RowsLeft>= n) {
                   TimeList[row + n].setText(String.valueOf(Double.parseDouble(TimeList[row - 1 + n].getText().toString()) + (AdditionTimeSeconds/60)));
                   n++;
               }
              row++;
              TopicTimer[row-1].start();
           }
       }
   });

此循环,
while(TimeList[row].getText()!=“null”){RowUsed++;}
将永远不会退出。你想干什么?另外,您不能使用
比较字符串=。请理解字符串是对象,而不是原语。阅读有关在Java中比较字符串的内容。最后,如果您使用适当的Java命名约定,您的代码将更易于阅读。While循环将检查每个timeuntiltopxends的文本,直到没有任何内容写入其中(我用null表示),因为如果没有选择,则从未有文本应用于它们。这样我就可以计算出表中还剩下多少行,直到使用end->strored in rows。我不知道这些约定,我想我应该读一下:O.写代码的人之一,但不太了解它:/-->但我的意思是,如果TextView中没有写文本,TextView.getText应该为null,对吗?这是在异步任务中运行的吗?请仔细阅读该循环。正如我所说,它永远不会退出,因为
将始终具有相同的值。并且不能使用!=投票结束,因为你没有听。考虑到我不知道我现在要说的是什么任务。它是从onCreate()调用的ButtonFunctionality()方法中的simpe onClickListener。我还有一个启动和停止按钮在那里,工作良好。