Hi,

I saw this problem as well. To workaround it I created a boolean flag
in my anonymous instance of AnimationListener so that it only happens
once.

                        animSet.setAnimationListener(new AnimationListener() {
                                private boolean ended = false;
                                @Override
                                public void onAnimationEnd(Animation animation) 
{
                                        if (ended)
                                                return;

                                        ended = true;
                                        animation.reset();
                                        clearAnimation();
                                      ...
Cheers,
Brady

On Dec 16 2011, 6:06 pm, "Tommy Hartz" <droi...@gmail.com> wrote:
> Hi,
>
> I am trying to fade an ImageView Out, change the Image, then fade it back
> in. Here is the code I am using:
>
> private void fadeOut(){
>
>             AnimationSet myAnimationOut = new AnimationSet(true);
>
>             myAnimationOut.setAnimationListener(new AnimationListener(){
>
>                   @Override
>
>                   public void onAnimationEnd(Animation arg0) {
>
>                         currWeatherAdRotator.clearAnimation();
>
>                         if(currAd == 0){
>
> currWeatherAdRotator.setBackgroundResource(R.drawable.lbanner2);
>
>                               currAd = 1;
>
>                         }else if(currAd == 1){
>
> currWeatherAdRotator.setBackgroundResource(R.drawable.lbanner3);
>
>                               currAd = 2;
>
>                         }else if(currAd == 2){
>
> currWeatherAdRotator.setBackgroundResource(R.drawable.lbanner4);
>
>                               currAd = 3;
>
>                         }else if(currAd == 3){
>
> currWeatherAdRotator.setBackgroundResource(R.drawable.lbanner1);
>
>                               currAd = 0;
>
>                         }
>
>                         fadeIn();
>
>                   }
>
>                   @Override
>
>                   public void onAnimationRepeat(Animation arg0) {
>
>                         // TODO Auto-generated method stub
>
>                   }
>
>                   @Override
>
>                   public void onAnimationStart(Animation arg0) {
>
>                         // TODO Auto-generated method stub
>
>                   }
>
>             });
>
> It seems however that currWeatherAdRotator.clearAnimation(); causes this bit
> of code to run twice which messes up my sequence. If I remove
> currWeatherAdRotator.clearAnimation(); It creates a black flicker at the end
> of the animation.
>
> I have the fadeout feature set up on a timer that goes off every 15 seconds.
> I tried creating a new class that extends the ImageView (as I read was a
> work around) but when I do this I can't run my timers because I get an error
> when calling runOnUiThread.
>
> Basically I want to rotate through these image every 15 seconds
> continuously. Can someone please tell me how I can do this or what I am
> doing wrong?
>
> Thanks for your help!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to