I can only generate one number at a time. How can I generate one number then after a second of delay it will automatically generate another one until I press stop?
public void generate(View view) throws InterruptedException {
Random rand = new Random();
int number = rand.nextInt(20)+1;
TextView myText = (TextView)findViewById(R.id.textView);
String myString = String.valueOf(number);
myText.setText(number);
TimeUnit.SECONDS.sleep(1);
}
I can only generate one number at a time. How can I generate one number then after a second of delay it will automatically generate another one until I press stop?
public void generate(View view) throws InterruptedException {
Random rand = new Random();
int number = rand.nextInt(20)+1;
TextView myText = (TextView)findViewById(R.id.textView);
String myString = String.valueOf(number);
myText.setText(number);
TimeUnit.SECONDS.sleep(1);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.