我一直在試圖創建一個代碼,將倒計時到聖誕節的android應用程序。如何創建聖誕倒計時
這是我到目前爲止。
Calendar thatDay = Calendar.getInstance();
thatDay.setTime(new Date(0)); /* reset */
thatDay.set(Calendar.DAY_OF_MONTH, 25);
thatDay.set(Calendar.MONTH, 11); // 0-11 so 1 less
thatDay.set(Calendar.YEAR, 2014);
Calendar today = Calendar.getInstance();
while (true)
{
long diff = thatDay.getTimeInMillis() - today.getTimeInMillis();
long diffSec = diff/1000;
long days = diffSec/SECONDS_IN_A_DAY;
long secondsDay = diffSec % SECONDS_IN_A_DAY;
long seconds = secondsDay % 60;
long minutes = (secondsDay/60) % 60;
long hours = (secondsDay/3600); // % 24 not needed
}
但是,當我嘗試循環它時,它會產生太多的輸出。我怎樣才能每秒顯示代碼更新?
請幫忙!!
甚至在聖誕節之後;) – rzysia 2014-12-04 14:54:04
小錯字,'i
Compass
2014-12-04 15:01:42
@compass是的,當我在iPhone上使用縮略圖代碼時,我有些錯誤。固定,thx。 – Bohemian 2014-12-04 15:07:32