vendredi 27 novembre 2015

How to make Random sound when button click?

So i have 4 sound here, i was use SoundPool

     sound1 = soundPool.load(this, R.raw.aww, 1);
     sound2 = soundPool.load(this, R.raw.arh, 1);
     sound3 = soundPool.load(this, R.raw.agg, 1);
     sound4 = soundPool.load(this, R.raw.uhh, 1);

so i wonder how to make button choose random sound :

    click= (Button)findViewById(R.id.bm);
    click.setOnClickListener(new View.OnClickListener() {

          public void onClick(View click){             
             //choose one of four sound to play   
            }
        });
}

Anyone have some Idea?




Aucun commentaire:

Enregistrer un commentaire