Android button click to play music, click again to stop music
I have a button, when I click it plays music, how to do it, when I click
second time, to stop the music?
Button two = (Button)this.findViewById(R.id.button2);
final MediaPlayer mp2 = MediaPlayer.create(this, R.raw.two);
two.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
mp2.start();
}
});
No comments:
Post a Comment