OK, I'm having an issue that I don't understand in my Android app. In the code below, I'm getting an error on the MediaPlayer mpWeight = MediaPlayer.create(this, R.raw.mppig)
;
Holding my cursor over create says:
The method create(Context, int)
in the type MediaPlayer
is not applicable for the arguments (new View.OnFocusChangeListener(){}, int
)
What does that mean, and more importantly, how do I resolve it?
Here's the whole routine:
TextView tv=(TextView)findViewById(R.id.weight);
tv.setOnFocusChangeListener(new OnFocusChangeListener(){
@Override
public void onFocusChange(View v,boolean hasFocus){
/* When focus is lost check that the text field
* has valid values.
*/
if (!hasFocus) {
float tempweight = Float.parseFloat(et_weight.getText().toString());
if(tempweight > 200){
MediaPlayer mpWeight = MediaPlayer.create(this, R.raw.mppig);
mpWeight.start();
}
}
}
});