title: Android, how to cancel blinking animation on TextView?
body: <p>I'm trying to enable and disable blinking animation on textview.</p>
  
  <p>Start blinking works fine but stop blinking does usin:</p>
  
  <pre><code>anim.cancel();
  anim.reset();
  </code></pre>
  
  <p>is not working and throws Null pointer exception. (But i dont know why, because variable is initialized).</p>
  
  <p>How can i solve that please? Thanks for any advice. </p>
  
  <p>Here is my code></p>
  
  <pre><code>private Animation anim;
  
  
  public void startBlinkText() {
          TextView myText = (TextView) findViewById(R.id.state);
          anim = new AlphaAnimation(0.0f, 1.0f);
          anim.setDuration(200); //You can manage the time of the blink with this parameter
          anim.setStartOffset(20);
          anim.setRepeatMode(Animation.REVERSE);
          anim.setRepeatCount(Animation.INFINITE);
          myText.startAnimation(anim);
      }
  
      public void stopBlinkText() {
          try {
              // TextView myText = (TextView) findViewById(R.id.state);
              anim.cancel();
              anim.reset();
              // myText.startAnimation(anim);
          } catch (Exception e) {
              Log.e(AppHelper.APP_LOG_NAMESPACE,
                      "stopBlinkText method cannot be processed", e);
              e.printStackTrace();
          }
      }
  </code></pre>