Skip to content Skip to sidebar Skip to footer

Android: Replace Sound Of Onclick

I have this code: Button boton = (Button) findViewById(R.id.boton); boton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); when I

Solution 1:

Try this:

publicclassMyActivityextendsActivity {

publicMyActivity(Bundle onSavedStateInstance) {
    MediaPlayermp= MediaPlayer.create(this, R.raw.mamacita_zero);

    Buttonzero= (Button)this.findViewById(R.id.btnZero);
    zero.setOnClickListener(newView.OnClickListener() {
        @OverridepublicvoidonClick(View v) {
            mp.start();
        }
    });
}

}

Solution 2:

You can add sound to your raw folder, initialize it

MediaPlayermpSplash= MediaPlayer.create(this, R.raw.slow);

and call it where ever required

    mpSplash.start();

Post a Comment for "Android: Replace Sound Of Onclick"