If I use handler.postDelayed
with the following order (delaying 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);
then everything goes smooth. However, if I change the order (delaying 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);
the application crashes with the message "Unfortunately, my app has stopped working". I am curious about the reason for this result... Thanks