@Bind(R.id.resultShow)
TextView showTime;
private Handler mHandler = new Handler();
private int timeLenth = 5;//计时5秒
Runnable runnable = new Runnable() {
@Override
public void run() {
if (timeLenth >= 0) {
showTime.setText(timeLenth + "");
timeLenth--;
mHandler.postDelayed(this, 1000);
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mHandler.postDelayed(runnable, 1000);
}
计时器
最新推荐文章于 2024-06-05 15:33:33 发布