title: Enabling only one button to execute at a time from multiple buttons in android
body: <p>I have a list of image buttons which when clicked each plays a song. The problem is that I can click a button continuously thus enabling the same music to play for each button clicked.  </p>
  
  <p>I can also  click a different button in the <code>switch()</code> case method while the music of the other button is still playing.  </p>
  
  <p>How can i disable the working of multiple click when one one is in execution? Please see my code for reference. </p>
  
  <pre><code>@Override
  public void onClick(View v) {
  
      // TODO Auto-generated method stub
      switch(v.getId()){
      case R.id.imageButton1:
  
          // TODO Auto-generated method stub
      sound1=MediaPlayer.create(Learn_Emela.this, R.raw.song2);
      Toast.makeText(getApplicationContext(), "Tingg..", Toast.LENGTH_LONG).show();
      sound1.start();
         break;
  
      case R.id.imageButton2:
          // TODO Auto-generated method stub
          sound1=MediaPlayer.create(Learn_Emela.this, R.raw.song2);
          Toast.makeText(getApplicationContext(), "Tingg..", Toast.LENGTH_LONG).show();
          sound1.start();
          break;
      case R.id.imageButton3:
  
          // TODO Auto-generated method stub
          sound1=MediaPlayer.create(Learn_Emela.this, R.raw.song3);
          Toast.makeText(getApplicationContext(), "Tingg..", Toast.LENGTH_LONG).show();
          sound1.start();
  
  
          break;`
  </code></pre>