好的,我正在为 android 制作动态壁纸,我希望根据一天中的什么时间来更改即时显示的鱼。所以我将它添加到循环线程中
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 语句时,它说它不能是静态的。我应该如何实现此代码,使其不是静态的?