TimerTask倒计时
生活随笔
收集整理的這篇文章主要介紹了
TimerTask倒计时
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
引導(dǎo)頁 TimerTask倒計(jì)時(shí)
package com.umeng.soexample;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.Timer;
import java.util.TimerTask;
public class LoadingActivity extends AppCompatActivity {
private ImageView image; private TextView text; private int count = 3;@Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_loading);image = findViewById(R.id.imageview);text = findViewById(R.id.textview);TimerTask timerTask = new TimerTask() {@Overridepublic void run() {runOnUiThread(new Runnable() {@Overridepublic void run() {text.setText(count+"S");if(count == 0){Intent intent = new Intent(LoadingActivity.this,MainActivity.class);startActivity(intent);finish();}}});count--;}};Timer timer = new Timer();timer.schedule(timerTask,1,1000); }}
總結(jié)
以上是生活随笔為你收集整理的TimerTask倒计时的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 回车判断_java 判断输入回
- 下一篇: oracle utl_file权限,Or