Let me clarify. I am creating a soundboard (android application) for a class of mine and I used this method 30 times, one for each button/mp3
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class pageOneSounds extends Activity {
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
setContentView(R.layout.pageonesounds);
final MediaPlayer pg1 = MediaPlayer.create(this, R.raw.sound1);
Button playSound1 = (Button) this.findViewById(R.id.sound1Button);
playSound1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pg1.start();
}
});
So this method works well, but I am going to have 30 buttons with a scroll view on this layout. I was wondering if there is a method I could use that would allow me to have just one method and not have to copy and paste that .setOnClickListener 30 times. Let me know if I am making sense or not. Really new to java and android I don't really know what I'm doing/might not understand you.