Thread.sleep() skips to last method in Java/Android
While there must be a better tactic of completing a countdown I have set
up in my app, it seemed clear to me that using Thread.sleep(1000) between
every digit would work. It did not and I still do not have any other
solution. When I run the app, the countdown goes from 5, straight to 1 in
1 second.
This is my code:
bBegin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bBegin.setText("5");
try{
Thread.sleep(1000);
}catch(InterruptedException ie){
}
bBegin.setText("4");
try{
Thread.sleep(1000);
}catch(InterruptedException ie){
}
bBegin.setText("3");
try{
Thread.sleep(1000);
}catch(InterruptedException ie){
}
bBegin.setText("2");
try{
Thread.sleep(1000);
}catch(InterruptedException ie){
}
bBegin.setText("1");
try{
Thread.sleep(1000);
}catch(InterruptedException ie){
}
Thanks, I hope this problems helps other noobs like me (and no worries, I
did check the site for a previous solution)
No comments:
Post a Comment