【问题标题】:The Main Activity not showing after the Animated Splash Screen动画启动屏幕后未显示主要活动
【发布时间】:2013-04-17 02:19:28
【问题描述】:

我尝试做一个动画启动画面,问题是在启动画面之后没有显示 MainActivity。我添加了一些代码,但它使它崩溃。你能帮我吗。 下面是启动屏幕活动的代码

   public class SplashScreenActivity extends Activity {
 public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Window window = getWindow();
        window.setFormat(PixelFormat.RGBA_8888);
    }
  /** Called when the activity is first created. */
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       CountDown _tik;
       _tik=new CountDown(3000,3000,this,MainActivity.class);// It delay th
  screen for 3 second and after that switch to my MainActivity
       _tik.start();
       StartAnimations();
       }


   private void StartAnimations() {
   Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
   anim.reset();
   LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
   l.clearAnimation();
   l.startAnimation(anim);

   anim = AnimationUtils.loadAnimation(this, R.anim.translate);
   anim.reset();
   ImageView iv = (ImageView) findViewById(R.id.logo);
   iv.clearAnimation();
   iv.startAnimation(anim);



   }

倒计时代码下方

public class CountDown extends CountDownTimer{
private Activity _act;
private Class _cls;
public CountDown(long millisInFuture, long countDownInterval,Activity act,Class cls) {
super(millisInFuture, countDownInterval);
_act=act;
_cls=cls;
}
@Override
public void onFinish() {
_act.startActivity(new Intent(_act,_cls));
_act.finish();
}
@Override
public void onTick(long millisUntilFinished) {

}

最后一个是我想要在启动画面之后显示的活动

    public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

请注意。动画效果很好。唯一的问题是当我试图在启动画面后获取 MainActivity 时。

【问题讨论】:

  • 请放错误日志

标签: java android eclipse


【解决方案1】:

您是否错过了设置动画侦听器?我认为你必须从动画监听器的 onAnimationEnd 方法调用你的主要活动。可能这会帮助你Question 会帮助你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多