Java android MediaPlayer中的原始问题
我对按钮的声音有意见。即使我在“res”文件夹(res/raw)中创建文件夹,也不能使用“raw”。Eclipse问我是否要在R文件中创建它…它方便吗??请帮忙。任何帮助都是适当的 这个想法是当我点击一个ImageButton时,我会听到图像的颜色Java android MediaPlayer中的原始问题,java,android,Java,Android,我对按钮的声音有意见。即使我在“res”文件夹(res/raw)中创建文件夹,也不能使用“raw”。Eclipse问我是否要在R文件中创建它…它方便吗??请帮忙。任何帮助都是适当的 这个想法是当我点击一个ImageButton时,我会听到图像的颜色 MediaPlayer mp1 = MediaPlayer.create(this, R.raw.sound1); public void dos(View v) { TextView f = (TextView) findViewB
MediaPlayer mp1 = MediaPlayer.create(this, R.raw.sound1);
public void dos(View v) {
TextView f = (TextView) findViewById(R.id.pts);
TextView t = (TextView) findViewById(R.id.color);
c++;
if (t.getText().toString().equals("YELLOW")) {
Toast.makeText(this, "Correct", Toast.LENGTH_SHORT).show();
pts++;
color(v);
mp1.start();
f.setText(Integer.toString(pts));
} else {
Toast.makeText(this, "Fail", Toast.LENGTH_SHORT)
.show();
}
}
唯一的问题是在这方面
MediaPlayer mp1 = MediaPlayer.create(this, R.raw.sound1);
raw带下划线,表示需要在R文件中创建字段或常量。尝试更改:
MediaPlayer mp1 = MediaPlayer.create(this, R.raw.sound1);
为此:
`final MediaPlayer mp1 = MediaPlayer.create(this, R.raw.sound1);`
是否导入了正确的资源类?应该是.R