I have a activity where I have multiple ImageViews and when you click on it the ImageView will fade out and fade back in. What I'm trying to figure out is how I can click one ImageView and start the animation and when I click a 2nd one and the animation is still running it will ignore the second one. I think I need to do something with the animationListener but I can't figure out how to use that to check if the animation is running or not before I initiate a new animation. I could have sworn I saw an example that did this but I've been looking for days and can't find it anymore, I'm hoping someone would be able to help out here..... below is the code for my animation:
// Create Animation protected void fadeAnimation() { tempImg.startAnimation(fadeout); //Allow animation to finish mHandler.postDelayed(new Runnable() { public void run() { tempImg.startAnimation(fadein); } }, 1000); }
I'm assuming both fadeout and fadein are Animation
objects.
Use fadeout.hasEnded()
to check if the first has finished before starting your second one.
For more details about the Animation
class, see here: http://developer.android.com/reference/android/view/animation/Animation.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With