2011-10-03 45 views
0

這有點奇怪,但我不知道問題出在哪裏。Android,處理程序的錯誤

在我的onCreate()我有這樣的代碼:

GameRunningNotesTimer().start(); 

,然後出來的onCreate我有這樣的代碼:

Thread GameRunningNotesTimer = new Thread(new Runnable() { 

    public void run() { 

     int sleepingTime; 
     try { 
      if (r_settings.getGameOver() == 0) { 

       sleepingTime = 1000 - (r_settings.getInternalLevel() * 100); 

       if (r_settings.getInternalLevel() == 0) { 
        Thread.sleep(1000); 
       } else { 
          if (sleepingTime <= 399) 
          { 
           sleepingTime = 350; 
          } 
          Thread.sleep(sleepingTime); 
         } 
        if (r_settings.getGameOver() == 1){ gameOver(); } 

       myHandler2.sendEmptyMessage(0); 
      } // End of if (r_settings.getGameOver() 
     } catch (Exception e) { Log.e("MUSIC!!!!!", "Error in activity", e); } 
    }// End of run 
}); // End of GameRunningNotesTimer() 




final Handler myHandler2 = new Handler() { 

    @Override 
    public void handleMessage(Message msg) { 

     //text2.setText(""+item[0]); 
     int z = 1; 

     if (r_settings.getGameStarted() == true) 
     { 
      changeNoteFromTimer(); 
     } else { 
      startingCountdown(z); 
     } 

    } // end of handleMessage() 

}; 

但這GameRunningNotesTimer()。開始();在紅色下劃線(在Eclipse中),當我將鼠標懸停時,它會顯示:The method GameRunningNotesTimer() is undefined for the type GameScr

我在做什麼錯?另一個同類的線程/處理程序不會給我這個問題。

謝謝!

回答

2

應該GameRunningNotesTimer.start();GameRunningNotesTimer().start();

+0

爾加!太愚蠢了......這就是爲什麼即使搜索文本沒有給我任何錯誤...謝謝你! – Ryan

+0

只要服用一顆冷藏藥丸的朋友,它有時候不用擔心。 :) –