I have this method:
public void onClick(View v) {
if (test != true) {
test = true;
start = System.currentTimeMillis();
end = System.currentTimeMillis() - start;
DateFormat df = new SimpleDateFormat("HH 'hours', mm 'mins,' ss 'seconds'");
df.setTimeZone(TimeZone.getTimeZone("GTM+0"));
tv.setText(df.format(new Date(end)));
} else {
DateFormat df = new SimpleDateFormat("HH 'hours', mm 'mins,' ss 'seconds'");
end = System.currentTimeMillis() - start;
df.setTimeZone(TimeZone.getTimeZone("GTM+0"));
tv.setText(df.format(new Date(end)));
}
I would like to have the “tv” variable keep outputting the time value, without stop after the “else” statement – so I will always see the current value of the time.
I have try to make a loop through a boolean, but without success.
I highgly recommend using a
Handlerfor the job.Having already answered this question before, you may find my answer here. It’s a complete program.
Good luck.