title: How to remove a View when animation ends?
body: <p>I'm creating a game and I would like to display a simple "score"-animation to the player when credits are given to him. This is the view I throw onto the screen:</p>
  
  <pre><code>public class Score extends FrameLayout {
  
    public Score(Context context, int score) {
      super(context);
      TextView txt = new TextView(context);
      txt.setText(String.valueOf(score).toUpperCase());  
      addView(txt);
      Animation anim = AnimationUtils.loadAnimation(context, R.anim.score);
      startAnimation(anim);
      anim.setAnimationListener(animationListener);
    }
    private void Remove(){
  
      ViewGroup parent = (ViewGroup)getParent();  
      parent.removeView(this);
  
    } 
    private AnimationListener animationListener = new AnimationListener() {
  
      @Override
      public void onAnimationEnd(Animation animation) {
  
        Remove();
      }  
    };
  }
  </code></pre>
  
  <p>This code actually works pretty well as long as there is only ONE score animation on screen at any given time. If the player scores again, before the last score was removed, the app crashes - probably because the second score gets the event to remove itself during animation.. Is this a bad practice of using Animation? How would you guys handle this?</p>