When I click on the Image Button(that should start the Chronometer ) the Chronometer doesnt start from 00:00 , but from the time the app is running . For example if I open the app and wait 10 sec , when I'll click on the Imageutton then the Chronometer will strat from 00:10 .. What should I do in order to start the Chronometer from 00:00 whenever i click on the image button ?
Here is my code:
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Chronometer;
import android.widget.ImageButton;
import android.os.SystemClock;
public class MainScreen extends Activity {
Chronometer focus;
ImageButton start;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
start=(ImageButton)findViewById(R.id.FingerStartImageBtn);
focus=(Chronometer)findViewById(R.id.timer);
focus.setBase(SystemClock.elapsedRealtime());
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
focus.start();
}
});
}
}