나는 Calendar
개체가
Calendar cal = Calendar.getInstance();
int hh = cal.get(Calendar.HOUR);
int mm = cal.get(Calendar.MINUTE);
int ss = cal.get(Calendar.SECOND);
그리고 시간 형식화
SimpleDateFormat sdf = new SimpleDateFormat("h:mm:s a", Locale.US);
TextView
카운트 다운 시간을 hh:mm:ss
형식으로 표시 하고 싶습니다.
Time left: 03:25:12
Time left: 03:25:11
Time left: 03:25:10
Time left: 03:25:09
.
.
. so on and stop the countdown after 3 hours, 25 minutes and 8 seconds.
시간이 지나면 TextView
이 표시되어야합니다 Time left: 00:00:00
.
Timer 클래스를 다음과 같이 사용하십시오.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
long maxTimeInMilliseconds = 3*25*8*1000;// in your case
startTimer(maxTimeInMilliseconds, 1000);
}
public void startTimer(final long finish, long tick)
{
t = new CountDownTimer(finish, tick) {
public void onTick(long millisUntilFinished)
{
long remainedSecs = millisUntilFinished/1000;
timer.setText(""+(remainedSecs/60)+":"+(remainedSecs%60));// manage it accordign to you
}
public void onFinish()
{
timer.setText("00:00:00");
cancel();
}
}.start();
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다