此代码应该在单击按钮时执行我设置的动画,等待动画完成,然后加载新 Activity 。当我尝试添加监听器时,我的 Intent 构造函数出现错误。任何帮助都会很棒。
public void onClick (View v) {
switch (v.getId()){
case R.id.buttonStart:
wobble.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
buttonStart.startAnimation(wobble);
}
@Override
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(this,CityRendActivity.class));
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
break;
}
}
}
最佳答案
看起来您在 onAnimationEnd
中传递的 this
是正在创建的 AnimationListener
。您需要指定要传递给 Intent
构造函数的 this
是您的 Activity :
@Override
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(MyActivity.this, CityRendActivity.class));
}
关于java - Intent 的动画监听器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34774680/