2012-08-08 18 views
0

好吧即時製作一個動態壁紙的android和我想改變魚im顯示取決於一天中的什麼時間。 所以我加入到循環螺紋基於一天中的時間改變精靈

public static int getCurrentHour() { 
    // TODO Auto-generated method stub 
    //i set getfishcolor 
    int getFishColor = 0; 
    final Calendar c = Calendar.getInstance(); 
    int t = Calendar.AM_PM; 
    final int h = Calendar.HOUR; 
    int theHour = c.get(h); 
    int isAM = c.get(t); 
    //check the time to see what type it should be 
    if (theHour + isAM == 8 + isAM) 
    { getFishColor = 0;} 
    //this is then called in current_fish 
    else {getFishColor = 4;} 
    //restart loop somehow 
     return getFishColor; 
} 

的問題是使()這一點;在主類只運行一次,所以如果它已經設置的魚不會改變,但當我嘗試將它添加到我的if語句它說它不能是靜態的。我應該如何實現這個代碼,使其不是靜態的?

回答

0

解開畫布後,只需放入此代碼即可。這不需要靜態。假設你調用canvas persec/put邏輯多次調用它。

相關問題