Hello everybody,
I'm trying to make a simple countdown timer in which on the first layout you set the time in seconds you want it to count backwards and click on a button to set it and open the next Activity. (So far so good)
On the new layout of the second activity and a new layout you have two buttons (1) Start and (2) Stop. The idea is that when you press "Start" a progress bar is shown in a backwards fashion and a sound will be played (not implemented yet). If the "Stop" button is pressed the countdown should stop reinitialize and wait for the "Start" button to be pressed again.
The problem I'm having is once the countdown starts after pressing "Start" the countdown does not stop until it has completed the for loop. And once it finishes neither of the buttons do anything.:BangHead:
Here's my code:
** I don't have any code in the subs Activity_Resume or Pause, don't know if that will affect anything.
Thanks in advance.
I'm trying to make a simple countdown timer in which on the first layout you set the time in seconds you want it to count backwards and click on a button to set it and open the next Activity. (So far so good)
On the new layout of the second activity and a new layout you have two buttons (1) Start and (2) Stop. The idea is that when you press "Start" a progress bar is shown in a backwards fashion and a sound will be played (not implemented yet). If the "Stop" button is pressed the countdown should stop reinitialize and wait for the "Start" button to be pressed again.
The problem I'm having is once the countdown starts after pressing "Start" the countdown does not stop until it has completed the for loop. And once it finishes neither of the buttons do anything.:BangHead:
Here's my code:
B4X:
Sub btnStart_Click
For I=Main.T To 1 Step -1
PBar.Progress=(C*I) ' Math so Progress Bar looks good
Sleep(1000) ' Pause time for Progress Bar countdown
Next
End Sub
B4X:
Sub btnStop_Click
I=Main.T
End Sub
** I don't have any code in the subs Activity_Resume or Pause, don't know if that will affect anything.
Thanks in advance.