cr5315
Android Enthusiast
I'm making a very simple app, and I have a button that is supposed to play a sound when pressed. I've tried many things to get it to work, but no success. Here is my code
This makes the choose sound play when the app is opened, and it is supposed to, but I'm not sure how to make a button play a different sound.
Code:
package com.androidbook.droid1;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
public class DroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MediaPlayer mp = MediaPlayer.create(getBaseContext(), R.raw.choose);
mp.start();
}
}