设为首页 加入收藏

TOP

Android---闪频页和倒计时(二)
2017-10-13 10:47:30 】 浏览:4094
Tags:Android--- 倒计时
ty_splash_time);
tv_time= (TextView) findViewById(R.id.tv_time);
mc=new MyCountDownTimer(5000,1000);
mc.start();//启动倒计时
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(SplashTimeActivity.this,MainActivity.class);
startActivity(intent);
}
},5000);
}
private Handler handler=new Handler();
/**
* 定义一个倒计时的内部类
*/
class MyCountDownTimer extends CountDownTimer {
/**
*
* @param millisInFuture 从开始调用start()到倒计时完成并onfinish()方法被调用的毫秒数
* @param countDownInterval 接收onTick(long)回调的间隔时间
*/
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long l) {
tv_time.setText("倒计时"+l/1000);
}
@Override
public void onFinish() {
tv_time.setText("正在跳转");
}
}
}

xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/splasht2"
tools:context="com.msn.zn.splashdemo.SplashTimeActivity">
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:textSize="20sp"
android:text="闪一下"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />

</RelativeLayout>

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇从相册获取图片及调用相机拍照获.. 下一篇[APP] Android 开发笔记 004-Andr..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目