verridePendingTransition在Android

verridePendingTransition在Android

本文介绍了overridePendingTransition在Android SDK中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让改变在Android应用程序的两项活动之间的过渡。我发现,overridePendingTransition会做的工作,但它似乎并没有为我工作。这是code我正在使用:

I'm trying to get change the transition between two activities in an Android application. I found that overridePendingTransition would do the job, but it doesn't seem to work for me.This is the code I'm working with:

@Override
 public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.splash);

  ImageView logo = (ImageView) findViewById(R.id.ImageView01);
  Animation fade = AnimationUtils.loadAnimation(this, R.anim.fade_in);

  fade.setAnimationListener(new AnimationListener() {

   @Override
   public void onAnimationRepeat(Animation animation) {
    // TODO Auto-generated method stub

   }

   @Override
   public void onAnimationStart(Animation animation) {
    // TODO Auto-generated method stub

   }

   @Override
   public void onAnimationEnd(Animation animation) {
    startActivity(new Intent(FDSplashActivity.this,
      FDGameActivity.class));
    FDSplashActivity.this.finish();
          overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
   }

  });
  logo.startAnimation(fade);
}

这应该显示启动画面,淡入标志,然后切换到另一个活动。这样的作品,而不是行overridePendingTransition(R.anim.fade_in,R.anim.fade_out);.当我徘徊它在Eclipse中它只是说:该方法overridePendingTransition(INT,INT)是未定义的类型新Animation.AnimationListener(){}

It's supposed to show the splash screen, fade in a logo and then switch to another activity. That works, but not the line overridePendingTransition(R.anim.fade_in, R.anim.fade_out);.When I'm hovering it in Eclipse it just says: "The method overridePendingTransition(int, int) is undefined for the type new Animation.AnimationListener(){}"

请帮我。

推荐答案

overridePendingTransition是活动的方法。就像你做了呼叫完成(),请尝试使用

overridePendingTransition is a method of Activity. Just as you have done for the call to finish(), try using

FDSplashActivity.this.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);

这篇关于overridePendingTransition在Android SDK中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 17:10