2011-06-24 68 views
0

我有一個短暫的延遲啓動畫面,延遲後,它移動到splashscreen但我似乎無法覆蓋過渡,我不明白爲什麼......雖然過渡確實工作在調試模式很奇怪Android轉換不起作用

package com.example.android.bubblestrouble; 

import android.app.Activity; import android.content.Intent; import android.os.Bundle;

公共類隊延伸活動{

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    final int delay = 3000; 
    setContentView(R.layout.team); 
    Thread welcomeThread = new Thread() 
    { 
    int wait = 0; 

    @Override 
    public void run() 
    { 
     try { 
       super.run(); 
       /** 
       * use while to get the splash time. Use sleep() to increase 
       * the wait variable for every 100L. 
       */ 
       while (wait < delay) 
       { 
        sleep(100); 
        wait += 100; 
       } 
      } 
     catch (Exception e) 
     { 
      System.out.println("EXc=" + e); 
     } 
     finally 
     { 
      /** 
      * Called after splash times up. Do some action after splash 
      * times up. Here we moved to another main activity class 
      */ 
      startActivity(new Intent(Team.this, SplashScreen.class)); 
      Team.this.finish(); 
      Team.this.overridePendingTransition(R.anim.fade, R.anim.hold); 
     } 
    } 
    }; 
    welcomeThread.start(); 
} 

}

回答

0

直溶液。在活動開始時立即顯示您的飛濺圖像,並用計時器替換所需的佈局。像這樣的東西(onCreate事件Team活動):

ImageView splashImage = new ImageView(this); 
splashImage.setImageBitmap(splashBitmap); // or drawable/resource - as you like 
setContentView(splashImage); 
Thread timerThread = new Thread() { 
    @Override 
    public void run() { 
     sleep(3000); 
     Team.runOnUiThread(new Runnable() { 
      @Override 
      public void run() { 
       setContentView(R.layout.team); 
      } 
     }); 
    } 
} 
timerThread.start(); 
+0

感謝,雖然這個應用程序,心不是最好的做法。主要問題是,我不明白爲什麼overridePendingTransition不起作用。我正嘗試使用轉換效果,這是實現這個的最佳方法 – Chris

+0

也許問題出在睡眠週期?嘗試使用'睡眠(3000)'而不是增量 –