TextView textViewprompt2 = (TextView)findViewById(R.id.textView3);
textViewprompt2.setText("There will be a series of 10 questions");
TextView textViewprompt1 = (TextView)findViewById(R.id.textView4);
textViewprompt1.setText("There will be a series of 10 questions");
Thread.sleep(2000);
TextView textViewcountdown1 = (TextView)findViewById(R.id.textView4);
TextView textViewcountdown2 = (TextView)findViewById(R.id.textView3);
textViewcountdown1.setText("3");
textViewcountdown2.setText("3");
Thread.sleep(1000);
textViewcountdown1.setText("2");
textViewcountdown2.setText("2");
Thread.sleep(1000);
textViewcountdown1.setText("1");
textViewcountdown2.setText("1");
Thread.sleep(1000);
textViewcountdown1.setText("Go");
textViewcountdown2.setText("Go");
Thread.sleep(500);
为什么不工作它基本上跳过setText并且似乎只执行Thread.sleep()行
答案 0 :(得分:0)
我认为Thread.sleep()
睡眠与setText()
使用的线程相同,这就是TextViews不更新的原因。
我建议使用Timer(特别是CountDownTimer:http://developer.android.com/reference/android/os/CountDownTimer.html)来延迟更新TextView,而不是使用Thread.sleep。