星空网 > 软件开发 > 操作系统

Android 实现闪屏页和右上角的倒计时跳转

效果图:

Android 实现闪屏页和右上角的倒计时跳转images/loading.gif' data-original="http://images2015.cnblogs.com/blog/881556/201602/881556-20160223093021349-1917941961.png" />

闪屏页用到了handler和CountDownTimer类,还需配置一下Activity的主题,这里是:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 全屏主题的意思。

实现源码:

package com.example.shanping;import java.lang.ref.WeakReference;import com.example.shanping.MyActivity.MyCountDownTimer;import android.os.Bundle;import android.os.CountDownTimer;import android.os.Handler;import android.os.Message;import android.app.Activity;import android.content.Intent;import android.util.Log;import android.view.Menu;import android.widget.TextView;public class MainActivity extends Activity {  private MyCountDownTimer mc;   private TextView tv;  @Override  protected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    tv = (TextView) findViewById(R.id.textView1);     mc = new MyCountDownTimer(3000, 1000);     mc.start();    handler.postDelayed(new Runnable() {            @Override      public void run() {        Intent intent=new Intent(MainActivity.this,MyActivity.class);        startActivity(intent);      }    }, 3000);  }  private Handler handler=new Handler();  /**    * 继承 CountDownTimer 防范    *    * 重写 父类的方法 onTick() 、 onFinish()    */      class MyCountDownTimer extends CountDownTimer {     /**     *     * @param millisInFuture     *   表示以毫秒为单位 倒计时的总数     *     *   例如 millisInFuture=1000 表示1秒     *     * @param countDownInterval     *   表示 间隔 多少微秒 调用一次 onTick 方法     *     *   例如: countDownInterval =1000 ; 表示每1000毫秒调用一次onTick()     *     */    public MyCountDownTimer(long millisInFuture, long countDownInterval) {      super(millisInFuture, countDownInterval);     }        public void onFinish() {      tv.setText("正在跳转");     }        public void onTick(long millisUntilFinished) {      tv.setText("倒计时(" + millisUntilFinished / 1000 + ")");     }    }  }

 




原标题:Android 实现闪屏页和右上角的倒计时跳转

关键词:Android

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

海外仓种类:https://www.goluckyvip.com/tag/33296.html
海外仓注意事项:https://www.goluckyvip.com/tag/33298.html
海外仓专线:https://www.goluckyvip.com/tag/33299.html
产品标题书写:https://www.goluckyvip.com/tag/333.html
跨境电商:https://www.goluckyvip.com/tag/3330.html
海外仓转仓:https://www.goluckyvip.com/tag/33300.html
好事!亚马逊后台又一功能已上线!:https://www.kjdsnews.com/a/1836454.html
会员动态|良马律师事务所正式成为深圳市跨境电子商务协会副会长单位:https://www.kjdsnews.com/a/1836455.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流