2012-10-30 43 views
3

我需要在自定義視圖中設置動畫菜單。必須重新繪製時間間隔(約10),但在線程停止後重新繪製。用線程間隔重繪視圖

public void menuShift() { 
    Runnable runnable = new Runnable() { 
     public void run() { 
      while (TablesActivity.this.view.menuShifting) { 
       try { 
        Thread.sleep(100) ; 
       } catch (InterruptedException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
       TablesActivity.this.view.timerRefresh() ; 
       TablesActivity.this.view.postInvalidate() ; 
      } 
     } 
    } ; 
    this.menuShiftThread = new Thread(runnable) ; 
    this.menuShiftThread.run() ; 
} 

回答

1

this.menuShiftThread.run();是的問題,你需要

this.menuShiftThread.start() 

要真正開始一個新的線程。