我有这个结构:
1)主要活动:
public class mainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new GameView(this));
}
2) 游戏视图
SoundPool sp;
int mySound = 0;
public class GameView extends SurfaceView implements SurfaceHolder.Callback {
public GameView(Context context) {
super(context);
sp = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
mySound = sp.load(this, R.raw.mysound, 1);
}
在线“mySound = sp.load(this, R.raw.mysound, 1);” 它给了我错误-“SoundPool 类型中的方法 load(Context, int, int) 不适用于参数 (GameView, int, int)”。大佬们,怎么解决啊 当我使用“扩展活动”时它工作正常,但在 SurfaceView 中它不起作用。请帮忙。