animfadein = AnimationUtils.loadAnimation(getApplicationContext(),
R.drawable.fade_in);
// set animation listener
//animBlink.setAnimationListener(this);
opt1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
l1.startAnimation(animfadein);
startActivity(new Intent(MainActivity.this,SecondQuestion.class));
}
});
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<alpha
android:duration="10000"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0" />
我希望这个动画完全执行然后应该调用下一个活动我该如何实现。在10000秒之前,已经调用了下一个活动。
答案 0 :(得分:1)
使用AnimationListener:
animfadein.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(MainActivity.this,SecondQuestion.class));
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});