gpt4 book ai didi

android - Android Studio添加声音错误

转载 作者:行者123 更新时间:2023-12-03 01:59:50 25 4
gpt4 key购买 nike

我正在尝试添加声音,但出现错误:Cannot resolve method 'create(com.game.tobias.game.Explosion, int'为什么要int?

码:

MediaPlayer explosion;
explosion = MediaPlayer.create(this, R.raw.mpExplosion)
explosion.start();

最佳答案

尝试使用getApplicationContext()获取上下文:

MediaPlayer explosion;
explosion = MediaPlayer.create(getApplicationContext(), R.raw.mpExplosion)
explosion.start();

关于android - Android Studio添加声音错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32592432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com