I am using kotlin in Android Studio. I am writing a simple program to display a series of random numbers with a delay of 1 second between each one. RandNumText is the name of the on screebn box. I have tried the following :-
enter code here
i=1 enter code here
while (i<10) { enter code here
RandNumText.text = ((0..9).random()).toString() enter code here
for (j in 0 until 50000) { enter code here
} enter code here
i++ enter code here
}
enter code here
i=1 enter code here
while (i<10) { enter code here
RandNumText.text = ((0..9).random()).toString() enter code here
Thread.sleep(1000) // wait for 1 second enter code here
i++ enter code here
}
enter code here
i = 1 enter code here
val handler = Handler() enter code here
while (i<10) { enter code here
handler.postDelayed({ enter code here
RandNumText.text = ((0 until 10).random()).toString() enter code here
}, 1000) enter code here
i++
enter code here
}
Each time just one number appears on screen. What am I doing wrong? Your assistance would be appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire