Reputation: 107
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! :)
Upvotes: 4
Views: 9339
Reputation: 36449
You should probably use String.valueOf()
so you get a String representation of the long
timerDisplayTop.setText(String.valueOf(cdDisplay));
Upvotes: 19