2013-03-22 3 views
0

나는 사용할 앱을 만들고있다 CountDownTimer 2 카운트 다운 동안 1 카운트 다운 타이머를 사용하고 싶다. 시간이 끝나면 즉시 새 시간이 시작됩니다.CounDownTimer 카운트를 2 번 설정하는 방법은 무엇입니까?

cdt = new CounDownTimer(time,1000) { 
    public void onTick(…) { 
     //code 
    } 
    public void onFinish() { 
     //and here I'm thinking to add a new time, but it doesn't work 
    } 
}; 

어떻게 그렇게 할 수있는 : 지금은

나는 이런 일이? 아니면 그 문제를 해결하는 다른 쉬운 옵션이 있습니까?

도움 주셔서 감사합니다.

답변

0

어딘가에 newMyCountdownTimer (시간, 간격) .start();

private class MyCountdownTimer extends CountDownTimer 
{ 


    public MyCountdownTimer(long millisInFuture, long countDownInterval) 
    { 
     super(millisInFuture, countDownInterval); 
    } 

    @Override 
    public void onFinish() 
    { 
     if (somecondition is satisfied) // be carefull otherwise the countdown keeps running 
     { 
     // newTime and newInterval are variables in the outer class 
      new MyCountdownTimer(newTime, newInterval).start(); 
     } 

    } 

    @Override 
    public void onTick(long millisUntilFinished) 
    { 
     // TODO Auto-generated method stub 

    } 

} 
+0

시간을 변경하려면 어떻게해야합니까? (예 : 10000, 5000이 아님)? 그렇게하는 방법? – Ganjira

+0

내 대답을 편집했습니다. –