Java代碼:...
onCreate{
...
final MediaPlayer mPlayer = new Media Player().create(this,R.raw.music);
mPlayer.start();
...
}
代碼是要實現在啟動界面播放音樂,結果as說
show references to static methods and fields via class instance rather than a classitself。不知是什麼意思,求賜教,今天被android studio 折磨死啦!
這句話的翻譯是你將靜態方法關聯到一個類的實例了,而不是一個類的本身。
靜態方法不允許實例化,而是應該用類名.靜態方法名來調用
final MediaPlayer mPlayer = new Media Player().create(this,R.raw.music);
你把這句改成
final MediaPlayer mPlayer = Media Player().create(this,R.raw.music);
你看看這個