1
私はアンドロイドの初心者です。今、私は簡単なアプリに取り組んでいます。私はアプリでタイマーを作成したい。私は10から0(それはユーザーに表示されます)からカウントダウンしたい、そして0であるとき、それはsmthを行う必要があります。 onTouchイベントが呼び出されるとカウントダウンを開始するはずです。私はこの方法で試しましたが、うまくいきません。誰でも助けてくれますか?Androidのタイマー
final MyCounter timer = new MyCounter(10000,1000);
public class MyCounter extends CountDownTimer{
public MyCounter(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
System.out.println("Timer Completed.");
time.setText("Timer Completed.");
}
@Override
public void onTick(long millisUntilFinished) {
time.setText((millisUntilFinished/1000)+"");
System.out.println("Timer : " + (millisUntilFinished/1000));
}
}
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN){
timer.start();
}
return false;