2011-05-15 102 views
0

這是我的代碼:兩人如何在不同的時間開始兩個不同的事件?

公共類閃屏延伸活動{

private ImageView poweredByImage; 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    setContentView(R.layout.splash); 

    poweredByImage = (ImageView)findViewById(R.id.ImageView); 
    poweredByImage.setImageResource(R.drawable.powered_by);   
    this.handleAnimation(poweredByImage); 

    Handler handler = null; 
    handler = new Handler(); 
    handler.postDelayed(new Runnable(){ 
     public void run(){ 
      Intent intent = new Intent(SplashScreen.this, HomeScreen.class); 
      startActivity(intent); 
     } 
    }, 3000); 
} 

public void handleAnimation(View v) { 
    v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); 
} 

}

我從一個屏幕(閃屏)導航到另一(主屏幕),3秒鐘時將出現的第一個後,但在此之前,我想在它出現1秒後開始淡入動畫,然後過渡到發生新屏幕。

那麼我該怎麼做呢?我應該使用什麼?任何幫助將是有用的!

回答

0

爲什麼不使用你的處理程序來發布Runnable負責在1000ms後啓動動畫?然後發佈你的第二個Runnable,在3000ms後開始你的HomeScreen活動,就像你正在做的那樣。

+0

我做到了,但有沒有更好的方法來做到這一點?一些替代? – nenito 2011-05-15 23:11:33

相關問題