一、需求和技术
1、实现5,4,3,2,1启动页倒计时
2、倒计时实现使用CountDownTimer
二、activity代码
public class OpenActivity extends AppCompatActivity {
private Button in;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open);
DBHelper.GetInstance(this.getApplication()).init();
in = findViewById(R.id.in);
CountDownTimer timer = new CountDownTimer(5000, 1000) {
public void onTick(long millisUntilFinished) {
in.setText(millisUntilFinished / 1000 + "秒");
}
public void onFinish() {
finishView();
}
};
timer.start();