4


I just read this: Android: How can I stop an infinite animation applied on an ImageView?, I tried it and it works perfectly, I set the animation in the onCreate() method of my Activity using AnimationUtils.loadAnimation(AppContext, animationRes), then I start the animation using startAnimation() and stop it using clearAnimation(). The problem I've got is that if I start another activity and then go back to the one with the animation, it doesn't work anymore. It looks like the animation is not even started, the listener attached to the animation doesn't enter the onAnimationStart(). Am I missing something here?

Thanks!

Community
  • 1
  • 1
futtetennista
  • 1,876
  • 1
  • 20
  • 33
  • 2
    Please indicate when you are calling `clearAnimation()` and please define what you mean by "it doesn't work anymore". – CommonsWare Nov 14 '10 at 23:28
  • I've got a helper method in a helper class to handle the animation of that View, so that `startAnimation()` is called (for example) when a screen is loading and `clearAnimation()` when that screen is loaded. The View is a static field of that helper class, and the helper method is called only when an activity starts. By "it doesn't work anymore" I meant that the View isn't animated anymore after I change screen. Btw I solved that by calling `findViewById` to find that View every time I need to start/stop the animation, but to be honest it's not really clear to me why that works. – futtetennista Nov 15 '10 at 16:47

1 Answers1

0

Where are you calling clearAnimation().

IMHO, I think you have to call startAnimation() at onResume() and call 'clearAnimation()' at onPause().

Check it out and tell us.

Urizev
  • 561
  • 6
  • 24