2017-03-01 20 views

回答

2

傳遞資源值可以integers這樣的:

public void playSound(View view, @RawRes int sound){ 
    mpSound = MediaPlayer.create(this, sound); 
    mpSound.start(); 
} 

調用你的方法是:

playSound(mView, R.raw.sound); 
0

它應該與@RawRes詮釋這樣一個整型:

public void playSound(View view, @RawRes int sound){ 
    mpSound = MediaPlayer.create(this, sound); 
    mpSound.start(); 
} 


你會看到這個錯誤如果您未通過原始資源:

Expected resource of type raw 
相關問題