title: Android: Hide animating button
body: <p>I'm a bit stuck again. This time i have an animated button, the animation is fading the button in and out. What i want to achieve is that when i press the button it should disappear. Sounds easy enough, but what I've tried so far doesn't work, and I'm guessing it's because the button is animated. </p>
  
  <p>I've tried setting the button.setVisibility(View.Invisible) in the onClick() listener.. My code is as follows:</p>
  
  <p>Animation: fade.xml</p>
  
  <blockquote>
    <blockquote>
  <pre><code>&lt;alpha xmlns:android="http://schemas.android.com/apk/res/android"
         android:fromAlpha="1.0"
         android:toAlpha="0.4"
         android:duration="1000"
         android:repeatCount="infinite"
         android:repeatMode="reverse"
          /&gt;  &lt;/set&gt;
  </code></pre>
    </blockquote>
  </blockquote>
  
  <p>I have a button declared in my layout xml called buttonStartTest
  and this is the code in the activity:</p>
  
  <pre><code>Button goButton = (Button) findViewById(R.id.buttonStartTest);
  
  goButton.setVisibility(View.VISIBLE);
  goButton.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade));
  goButton.setBackgroundResource(R.drawable.roundedcorners);
  goButton.setText("Start");
  goButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
          // click action here
          Button goButton = (Button) findViewById(R.id.buttonStartTest);
          goButton.setVisibility(View.INVISIBLE);
      }
  });
  </code></pre>
  
  <p>The problem is that the button doesn't disappear.. I can alter it in other ways in the onClick() though.. So my fellow coders, how do I go about hiding the button?</p>
  
  <p>much love,
  Daniel</p>