• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps [Eclipse Android] Timer with reset button

Useless to post on forums, no one helping me out ffs

Sorry to hear you say that, SnakeKoRn :(.

Some number of folks (sometimes myself included) don't often get to review this area until after we got off work (and it really was only a few hours since you first posted).

Also, for many folks to be able to help you, they'd need to load your code into Eclipse and debug and test it themselves--something I cannot do at work since my development machine is at home.

Anyway, I hope you'll post again and give folks a chance and some time to help you out.
 
Change your reset logic (near the bottom of the onCreate method) to include these two lines in red below:

Code:
 resetButton = (Button) findViewById(R.id.resetButton);
 resetButton.setOnClickListener(new View.OnClickListener() {
     public void onClick(View view) {
[COLOR="Red"][B]         timeSwapBuff = 0L;            [COLOR="Blue"]// was timeInMilliseconds[/COLOR]
         timerValue.setText("" + 0 + ":" + String.format("%02d", 0) + ":" + String.format("%03d", 0));[/B][/COLOR]
         customHandler.removeCallbacks(updateTimerThread);
     }
 });

You needed to reset the timeSwapBuff to 0 (zero) to make sure it resets instead of leaving off with the value when the timer was paused. You also needed to reset the text of the timerValue field to 00:00:000 to show the zeros as you wanted.

Cheers!
 
Omg!

I've been waiting so long for someone to help me out!
I'm forever grateful !

I apoligize for my previous reaction, I got frustrated.

You're doing a terrific job here.
You fixed the issue, and now I understand why it didn't work and how I can fix it in the future! :) Ty again!
 
Back
Top Bottom