title: Proper way to cancel animation for other items
body: <p>I have a container (GridLayout) in which I place multiple views. When I click on any of these views, an infinite animation should be applied (to indicate that it's the selected/chosen view).</p>
  
  <p>The problem is that I need to clear the previous animation so there's only one animation playing at a time (for the view that's clicked).</p>
  
  <p>I was thinking to have a global definition of animation and then simply cancel it onClick and assign a new View to it, but the ObjectAnimator has no method to cancel it. </p>
  
  <pre><code>GridLayout container = (GridLayout) filterPackContainer.findViewById( R.id.container );   
  
  for( int f=0; f&lt;10; f++ )
  {
      View child = that.getLayoutInflater().inflate( R.layout.child, null );
  
      child.setOnClickListener(new View.OnClickListener() 
      {
          @Override
          public void onClick(View v) 
          {
              ObjectAnimator anim = ObjectAnimator.ofFloat( v, "alpha", .5f, 1f );
              anim.setDuration( 1000 );
              anim.setRepeatMode( 2 );
              anim.setRepeatCount( 999999 );
              anim.start();
          }
      });
  
      container.addView( child );
  }
  </code></pre>
  
  <p>Then I tried to save the View as reference inClick, and cancel any existing animations using clearAnimation(), but this has no effect and the animation just keeps playing. </p>
  
  <pre><code>View vRef = null;
  
  ---------------------
  
  GridLayout container = (GridLayout) filterPackContainer.findViewById( R.id.container );   
  
  for( int f=0; f&lt;10; f++ )
  {
      View child = that.getLayoutInflater().inflate( R.layout.child, null );
  
      child.setOnClickListener(new View.OnClickListener() 
      {
          @Override
          public void onClick(View v) 
          {
              if( vRef != null )
                  vRef.clearAnimation();
  
              vRef = v;
  
              ObjectAnimator anim = ObjectAnimator.ofFloat( v, "alpha", .5f, 1f );
  
              anim.setDuration( 1000 );
              anim.setRepeatMode( 2 );
              anim.setRepeatCount( 999999 );
              anim.start();
          }
      });
  
      container.addView( child );
  }
  </code></pre>
  
  <p>any hints on how to handle this properly? Thanks! </p>