Java 根据一天中的时间更改精灵
好的,我正在为android制作一张实时壁纸,我想根据一天中的时间改变我显示的鱼。 所以我将它添加到循环线程中Java 根据一天中的时间更改精灵,java,android,static,bitmap,live-wallpaper,Java,Android,Static,Bitmap,Live Wallpaper,好的,我正在为android制作一张实时壁纸,我想根据一天中的时间改变我显示的鱼。 所以我将它添加到循环线程中 public static int getCurrentHour() { // TODO Auto-generated method stub //i set getfishcolor int getFishColor = 0; final Calendar c = Calendar.getInstance(); int t = Calendar
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语句时,它会说它不能是静态的。我应该如何实现这段代码,使其不是静态的 解锁画布后,只需放入此代码即可。这不需要静电干扰。假设您多次调用canvas persec/putted逻辑来调用它