title: Disable OnClickListener Android
body: <p>I have an <code>OnClickListener</code> on an image in my app. It allows the user to skip to a different part of the app if desired. The way the app runs, they can only use it 3 times.</p>
  
  <p>My issue is, I want to get fancy pants. So I added an <code>R.anim.fade_out</code> animation to make the image fade out after all 3 times were used. I am using a counter decreased by one in another method.</p>
  
  <p>The issue is, when the original method is recalled, it throws a <code>Null Reference Exception</code> because it can't find the image to set the <code>OnClickListener</code>. I tried wrapping it in an <code>If/Else If</code> statement:</p>
  
  <pre><code>if(skipsAllowed &gt; 0){
  
              skipButton.setOnClickListener(new OnClickListener(){
  
                  public void onClick(View v){
  
                      if(skipsAllowed &gt; 0){
                          try {
                              skippedPage();
                          } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                          }
                      }
  
                  }
              });
  
          }else  if(skipsAllowed == 0){
              skipFadeOut = AnimationUtils.loadAnimation(null, android.R.anim.fade_out);
              skipButton.startAnimation(skipFadeOut);
          }
  </code></pre>
  
  <p>This still didn't work. Any ideas on how to stop this?</p>
  
  <p>I instantiate the <code>ImageView</code> at the start of every new call to this <code>Activity</code>, should I be placing that inside my <strong>If/Else</strong> If?</p>