Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 根据一天中的时间更改精灵_Java_Android_Static_Bitmap_Live Wallpaper - Fatal编程技术网

Java 根据一天中的时间更改精灵

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

好的,我正在为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语句时,它会说它不能是静态的。我应该如何实现这段代码,使其不是静态的

解锁画布后,只需放入此代码即可。这不需要静电干扰。假设您多次调用canvas persec/putted逻辑来调用它