我有一个短暂延迟的启动屏幕,延迟后它会移动到启动画面上但是我似乎无法覆盖转换,我无法理解为什么......虽然转换确实在调试模式下工作,这很奇怪< / p>
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 :(得分: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();