Android: Playing sound when button clicked?
- by gazeebo
Hi all,
I'm trying to play a sound file when a button is clicked but keeps getting an error.
The error is "The method create(Context, int) in the type MediaPlayer is not applicable for the arguments (new View.OnClickListener(){}, int)"
Here's my code:
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Button zero = (Button)this.findViewById(R.id.btnZero);
zero.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mp = MediaPlayer.create(this, R.raw.mamacita_zero);
}
});
}
Any help or tips would be appreciated.
Thnx!