I'm trying to create a countdown timer for a reaction android app that I'm making (just to learn about threads and stuff), and am having trouble with the initial 3,2,1 portion of the code I'm creating.
long gameStart, elapsed, cdElapsed, countdownStart, cdDisplay;
TextView timerDisplayBottom, timerDisplayTop;
private void countdown() {
for(int i=1; i<10; i++) {
timerDisplayBottom.setText(cdDisplay);
timerDisplayTop.setText(cdDisplay);
cdElapsed = System.currentTimeMillis();
cdElapsed = (countdownStart - cdElapsed);
cdDisplay = (3 - cdElapsed);
}
}
I need to set the text of the timerDisplayBottom and Top to the number that cdDisplay generates.
Thanks in advance! :)
You should probably use String.valueOf()
so you get a String representation of the long
timerDisplayTop.setText(String.valueOf(cdDisplay));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With