package com.androidGreenPack.tools;
import android.content.Context;
import android.os.Handler;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* 顯示logo界面,倒計時n秒後,進入下一個頁面
* **/
public class LogoShow extends LinearLayout{
private Context mContext;
private int _number;
private TextView textView;
private Handler handler;
public LogoShow(Context context){
super(context);
mContext = context;
}
public void addLogoShow(){
textView = new TextView(mContext);
textView.setText("成功");
this.addView(textView);
//傳遞一個Runnable對象,1秒後執行該對象的run方法
handler = new Handler();
handler.postDelayed(run1,1000);
//執行的代碼
private Runnable run1 = new Runnable(){
public void run() {
String text = "";
text = ""+_number++;
textView.setText(text);
//再次傳遞一個Runnable對象,類似産生一種遞歸效果
if(_number == 10){
//移除回調
handler.removeCallbacks(run1);
textView.setText("跳轉");
}};