Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a TextView to a Long Value?

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! :)

like image 232
Kevin Chen Avatar asked Nov 30 '22 21:11

Kevin Chen


1 Answers

You should probably use String.valueOf() so you get a String representation of the long

timerDisplayTop.setText(String.valueOf(cdDisplay));
like image 155
A--C Avatar answered Dec 10 '22 12:12

A--C