如何将计时器时间保存到变量中?

时间:2014-05-05 13:56:22

标签: android

如果我按下停止按钮并且计时器在00:07停止,我该如何将该值保存为int?

View.OnClickListener mStopListener = new OnClickListener() {
    @Override
    public void onClick(View view) {
        Timer.stop();
        saveTime = Timer.getBase();
        Intent intent = new Intent(getApplicationContext(),
        TableScreen.class).putExtra("timer",saveTime);
        startActivity(intent);
    }
};

1 个答案:

答案 0 :(得分:1)

我弄明白了。

 View.OnClickListener mStopListener = new OnClickListener() {
    @Override
    public void onClick(View view) {
        Timer.stop();
        saveTime = SystemClock.elapsedRealtime() - Timer.getBase();
        int seconds = (int)(saveTime/1000 % 60);
        Intent intent = new Intent(getApplicationContext(),
        TableScreen.class).putExtra("timer",seconds);
        startActivity(intent);
    }
};