overridePendingTransition在Android SDK中不工作中不、工作、overridePendingTransition、Android

2023-09-12 22:21:19 作者:阳光未必暖人心

我试图让改变在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);