好的,我在我的 Android 应用程序中遇到了一个我不明白的问题。在下面的代码中,我在MediaPlayer mpWeight = MediaPlayer.create(this, R.raw.mppig)
;
将光标悬停在 create 上说:
create(Context, int)
类型中的方法MediaPlayer
不适用于参数 ( new View.OnFocusChangeListener(){}, int
)
这是什么意思,更重要的是,我该如何解决?
这是整个例程:
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();
}
}
}
});