new Handler().postDelayed(new Runnable() {
@Override
public void run() {
for(int i=0;i<5;i++){
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
position++;
tv.setText(position+"");
}
}
}, 3000);
问题: tv的文本不会2秒后变化一次,而是等循环结束后,在改变,求解