title: Toggle button visibility in android activity
body: <p>I have an activity with two play and pause buttons (currently invisible) and a seekbar. When I press the play button, the pause button should become visible, and when I press the pause button it should turn invisible.</p>
  
  <p>How would I do that?</p>
  
  <pre><code>import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.SeekBar;
  import android.widget.SeekBar.OnSeekBarChangeListener;
  
  
      public class MainActivity extends Activity implements Runnable, OnClickListener, OnSeekBarChangeListener{
          private SeekBar seekBar;
          private Button startMedia;
          private Button pauseMedia;
          private MediaPlayer mp;
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);             
  
              AudioControl();         
  
          }
  
          public void AudioControl(){
              seekBar = (SeekBar) findViewById(R.id.seekBar1);
              startMedia = (Button) findViewById(R.id.button1);
              pauseMedia = (Button) findViewById(R.id.button2);
              seekBar.setOnSeekBarChangeListener(this);
              startMedia.setOnClickListener(this);
              pauseMedia.setOnClickListener(this); 
          }
  
  
  
          public void run() {
              int currentPosition= 0;
              int total = mp.getDuration();
              while (mp!=null &amp;&amp; currentPosition&lt;total) {
                  try {
                      Thread.sleep(1000);
                      currentPosition= mp.getCurrentPosition();
                  } catch (InterruptedException e) {
                      return;
                  } catch (Exception e) {
                      return;
                  }            
                  seekBar.setProgress(currentPosition);
              }
          }
  
          public void onClick(View v) {
              if (v.equals(startMedia)) {
                  if (mp != null &amp;&amp; mp.isPlaying()) return;
                  if(seekBar.getProgress() &gt; 0) {
                      mp.start();
                      return;
                  }
                  mp = MediaPlayer.create(MainActivity.this, R.raw.lone);
                  mp.start();                     
                  seekBar.setProgress(0);
                  seekBar.setMax(mp.getDuration());
                  new Thread(this).start();
              }
  
              if (v.equals(pauseMedia) &amp;&amp; mp!=null) {
                  mp.pause();
              }       
  
          }
  
          public void onStartTrackingTouch(SeekBar seekBar) {
          }
  
          public void onStopTrackingTouch(SeekBar seekBar) {
          }
  
          public void onProgressChanged(SeekBar seekBar, int progress,
                  boolean fromUser) {
              if(fromUser) mp.seekTo(progress);
  
          }
      }
  </code></pre>
  
  <p><strong>I don't know where should I put blow code. please help me!</strong></p>