0

Stopwatch android question please help

click on the link below and scroll down.my question is the most recent post about timewatch https://plus.google.com/107321672913287932096

21st Nov 2017, 10:14 AM
oyl
13 odpowiedzi
+ 1
sorry i didnt get what you mean do you want to delete the handler?
21st Nov 2017, 5:37 PM
Alziber Mohammed
Alziber Mohammed - avatar
0
i meant like this If(running){ seconds++; postDelayed(this,1000); } when i put postDelayed(this,1000); inside the curly braces,the time watch stop working.why?
21st Nov 2017, 5:40 PM
oyl
0
could you show me the code
21st Nov 2017, 5:42 PM
Alziber Mohammed
Alziber Mohammed - avatar
0
sorry i cant see any error
21st Nov 2017, 6:09 PM
Alziber Mohammed
Alziber Mohammed - avatar
0
i have added comment in the code.u should be able to understand my question now
21st Nov 2017, 8:40 PM
oyl
0
oh sorry i got it right now in your code at the beginning of the watch it will check the value of "running" if it is true it will be repeated else it will stop being repeated you need to let it repeat even if the "running" is false by the way i think you are using Head first i suggest to you Android programming the big Nerd ranch guide 2nd edition Its very good i think
22nd Nov 2017, 4:35 AM
Alziber Mohammed
Alziber Mohammed - avatar
0
i asked why postdelayed cannot be inside the if statement.u didnt mention postdelayed method in your answer.
22nd Nov 2017, 9:41 AM
oyl
0
i meant when the postDelay() is in the if statement it will work just if its true but when you begin the app "running" is false so postDelay() wont work
22nd Nov 2017, 4:32 PM
Alziber Mohammed
Alziber Mohammed - avatar
0
if i put postDelay() in the if statement and press the start button.it doesnt start at all
22nd Nov 2017, 4:36 PM
oyl
0
postDelay() is inside runtimer() when the app begins the runtimer() works and see that "running" is false so postDelay() wont work and runTimer() wont work even if you changed the value of "running" unless you called it again
22nd Nov 2017, 6:00 PM
Alziber Mohammed
Alziber Mohammed - avatar
0
when i remove "handler.postDelayed(this, 1000);" it doesnt work too.why?i thought if running is true seconds will increment too...seconds++
23rd Nov 2017, 12:51 AM
oyl
0
can you explain why it works when i put handler.postDelayed(this, 1000); inside if statement.
23rd Nov 2017, 12:53 AM
oyl