0
我嘗試創建一個custome過去的時間,它會啓動計時器,一旦我拿着音量鍵,並假設時間必須停止後,我釋放的鑰匙,但我有問題時,我釋放的關鍵定時器仍在移動。請什麼我失蹤感謝指教停止在Android的更新時間
公共布爾的onkeydown(INT的keyCode,KeyEvent的事件){ 如果((的keyCode == KeyEvent.KEYCODE_VOLUME_DOWN & & shouldCont ==真& & event.getAction()==的KeyEvent .ACTION_DOWN)){ startRecord(); repeat = true; 如果(重複==真& & event.getAction()== KeyEvent.ACTION_DOWN){ t.scheduleAtFixedRate(新的TimerTask(){
public void run() {
runOnUiThread(new Runnable() {
public void run() {
long timeGoneMillis = System.currentTimeMillis() - startTime;
TextView tv = (TextView) findViewById(R.id.timer);
tv.setText(""+util.milliSecondsToTimer(timeGoneMillis));
}
});
}
},
//Set how long before to start calling the TimerTask (in milliseconds)
0,
//Set the amount of time between each execution (in milliseconds)
1000);}
shouldCont = false;
}