我尝试在使用淡入和淡出动画后打开另一个活动(在此代码中我使用intentHello)。但淡出后,它表示错误并关闭应用程序(不幸的是Myapplication2已停止工作)。这是我用过的代码。有人能帮助我吗? 提前致谢。
package com.example.ve.myapplication2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
public class MainActivity extends Activity implements AnimationListener {
private ImageView image;
private Animation animFadeIn;
private Animation animFadeOut;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = (ImageView) findViewById(R.id.my_image);
animFadeIn = AnimationUtils.loadAnimation(this, R.anim.anim_fade_in);
animFadeIn.setAnimationListener(this);
animFadeOut = AnimationUtils.loadAnimation(this, R.anim.anim_fade_out);
image.startAnimation(animFadeIn);
}
@Override
public void onAnimationEnd(Animation animation) {
Intent intentHello = new Intent(MainActivity.this, hello.class);
startActivity(intentHello);
}
@Override
public void onAnimationRepeat(Animation arg0) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation arg0) {
// TODO Auto-generated method stub
}
}