Hey all,
I'm trying to play a soundclip when ever a user clicks an imagebutton on the screen.
It works fine on the "physical keyboard" of the phone but I can't seem to get it to work when a user clicks on the screen.
I get the following message:
The method create(Context, int) in the type MediaPlayer is not applicable for the arguments (new View.OnClickListener(){}, int)
I'm trying to play a soundclip when ever a user clicks an imagebutton on the screen.
It works fine on the "physical keyboard" of the phone but I can't seem to get it to work when a user clicks on the screen.
I get the following message:
The method create(Context, int) in the type MediaPlayer is not applicable for the arguments (new View.OnClickListener(){}, int)
PHP:
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class DialPad extends Activity implements OnClickListener {
MediaPlayer mp;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button one = (Button) findViewById(R.id.btnOne);
one.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mp = MediaPlayer.create(this, R.raw.mamacita_one);
}
});
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent ev) {
switch (keyCode) {
case KeyEvent.KEYCODE_0:
mp = MediaPlayer.create(this, R.raw.mamacita_zero);
mp.start();
return true;
}
return super.onKeyDown(keyCode, ev);
}
}