我需要自定义视图中的动画菜单。必须每隔一段时间(大约 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() ;
}