Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.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_Android Studio_Timer_Countdowntimer - Fatal编程技术网

Java 在另一个班级开始倒计时?

Java 在另一个班级开始倒计时?,java,android,android-studio,timer,countdowntimer,Java,Android,Android Studio,Timer,Countdowntimer,我有一个Timer类,我在其中声明了倒计时,我希望在我的另一个类GameViewLv3中启动它,但我不知道如何做。我见过像我这样的问题,但我不明白答案。这是一个学校项目,请帮助我:) 这是我的计时器课 public class Timer { Content value = new Content(); int time = 60000; TextView pointsCounter; TextView timeCounter; private ImageButton character; p

我有一个Timer类,我在其中声明了倒计时,我希望在我的另一个类GameViewLv3中启动它,但我不知道如何做。我见过像我这样的问题,但我不明白答案。这是一个学校项目,请帮助我:)

这是我的计时器课

public class Timer {

Content value = new Content();
int time = 60000;
TextView pointsCounter;
TextView timeCounter;
private ImageButton character;
private RelativeLayout screenLayout;

final CountDownTimer countDown = new CountDownTimer(time, 1000) {

    public void onTick(long millisUntilFinished) {

        timeCounter.setText("" + millisUntilFinished / 1000);

        if (millisUntilFinished < 11000)
            timeCounter.setTextColor(Color.argb(255, 255, 0, 0));
    }

    public void onFinish() {
        timeCounter.setText("");
        pointsCounter.setTextColor(Color.argb(255, 255, 0, 0));
        character.setEnabled(false);
        character.setVisibility(character.INVISIBLE);
        screenLayout.setBackgroundResource(R.drawable.failedbg);
    }
};
}

这个计时器类是活动吗?如果上面的代码与你所做的完全一致,那么就缺少了很多东西。直接在你的活动中使用倒计时计时器…最初它是在我的主要活动中,但我的老师说我必须分成不同的班级:(
public class GameViewLvL3 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mainlvl3);
    Content Values = new Content();
    int time = 35000;
}
}