如果我使用handler.postDelayed
以下顺序(延迟startAnimation
):
animFadeout = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.disappear);
animFadeout.setAnimationListener(this);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
txtMessage.startAnimation(animFadeout);
}
}, 4000);
然后一切顺利。但是,如果我更改顺序(延迟loadAnimation
):
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
animFadeout = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.disappear);
}
}, 4000);
animFadeout.setAnimationListener(this);
txtMessage.startAnimation(animFadeout);
应用程序崩溃并显示消息“不幸的是,我的应用程序已停止工作”。我很好奇这个结果的原因......谢谢