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