计时器Chronometer

public class ChronometerActivity extends AppCompatActivity {
    private Chronometer chronometer = null;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chronometer);

        chronometer = findViewById(R.id.chronometer);
        chronometer.setBase(SystemClock.elapsedRealtime());
    }

    public void onStart(View view){
        chronometer.start();
    }
    public void onStop(View view){
        chronometer.stop();
    }
    public void onReset(View view){
        chronometer.setBase(SystemClock.elapsedRealtime());
    }
}

layout




    
    

计时器Chronometer_第1张图片

你可能感兴趣的:(android2019)