不确定如何在我的 android 秒表上表达我的重置操作

Not sure how to word my Reset action on my android stopwatch

我尝试了多种方法来解决我的问题,但我对编码还很陌生,所以我需要有关如何正确 'Word' 重置秒表的秒表动作的帮助。它需要做的就是以某种方式将当前值重置回 00:00:00,就像计时器启动之前一样,但我不确定该怎么做...这是 00:00:00 的部分=31=] 我正在努力解决的问题:

resetButton = (Button) findViewById(R.id.reset);
        return timeInMillies = startTime;
        resetButton.setOnClickListener(SystemClock.setCurrentTimeMillis(timeInMillies = 00:00:00))
        long timeInMillies = 0L;
        long timeSwap = 0L;
        long finalTime = 0L;
但是,其他一切都很好,并且很有魅力。如果对您有所帮助,请阅读完整的XML:

package com.jackson.eason.stopwatch;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.view.View;
import android.widget.Button;

import android.widget.TextView;


public class MainActivity extends Activity {

    /** Called when the activity is first created. */

    private Button startButton;
    private Button pauseButton;
    private Button resetButton;
    private long startTime = 0L;
    private Handler myHandler = new Handler();
    long timeInMillies = 0L;
    long timeSwap = 0L;
    long finalTime = 0L;

    private TextView textTimer;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textTimer = (TextView) findViewById(R.id.textTimer);

        startButton = (Button) findViewById(R.id.start);
        startButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                startTime = SystemClock.uptimeMillis();
                myHandler.postDelayed(updateTimerMethod, 0);
            }
        });

        pauseButton = (Button) findViewById(R.id.stop);
        pauseButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                timeSwap += timeInMillies;
                myHandler.removeCallbacks(updateTimerMethod);

            }
        });

        resetButton = (Button) findViewById(R.id.reset);
        return timeInMillies = startTime;
        resetButton.setOnClickListener(SystemClock.setCurrentTimeMillis(timeInMillies = 00:00:00))
        long timeInMillies = 0L;
        long timeSwap = 0L;
        long finalTime = 0L;



    }
    private Runnable updateTimerMethod = new Runnable() {

        public void run() {
            timeInMillies = SystemClock.uptimeMillis() - startTime;
            finalTime = timeSwap + timeInMillies;

            int seconds = (int) (finalTime / 1000);
            int minutes = seconds / 60;
            seconds = seconds % 60;
            int milliseconds = (int) (finalTime % 1000);
            textTimer.setText("" + minutes + ":"
                    + String.format("%02d", seconds) + ":"
                    + String.format("%03d", milliseconds));
            myHandler.postDelayed(this, 0);
        }

    };

}

非常感谢任何帮助!

对于重置按钮,您需要更改两处:

1) 文本框。

2) 保持startTime和timeSwap的变量。

但您不想更改应用程序的阶段,我将通过以下方式进行更改:

   resetButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            textTimer.setText("" + 00 + ":"
                    + String.format("%02d", 00) + ":"
                    + String.format("%03d", 00));
            startTime = SystemClock.uptimeMillis();
            timeSwap=0;
        }
    });