Reputation: 997
I am a newbie to android development and am trying to develop a simple application where a button is used to play a sound. I am trying to use SoundPool and find that every tutorial gives such a code to be added after making a soundpool object:
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
loaded = true;
}
});
but when i try to use this code in eclipse, it says
The method onLoadComplete(SoundPool, int, int) of type new SoundPool.OnLoadCompleteListener(){} must override a superclass method. and suggests to remove the @override notation. This should happen if there is no such method?? Why am i getting this error?
and when i put soundID = soundPool.load(this, R.raw.mysound, 1);
after the above code, eclipse says The method load(Context, int, int) in the type SoundPool is not applicable for the arguments (new View.OnClickListener(){}, int, int)
this is my entire code: public class FirstActivity extends Activity { /** Called when the activity is first created. */
private SoundPool soundPool;
int soundID;
boolean loaded = false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button bPlay = (Button) findViewById(R.id.bPlay);
final TextView aRing = (TextView)findViewById(R.id.tAlarmRinging);
bPlay.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
aRing.setVisibility(View.VISIBLE);
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
loaded = true;
}
});
soundID = soundPool.load(this, R.raw.mysound, 1);
}
});
}
}
Upvotes: 0
Views: 949
Reputation: 54322
You should try to set the project compliance level to java 1.7 or something like this.
Right click the project, goto Properties->Java Compiler->Check the Enable project specific settings->then select the highest compiler compliance level.
If this doesn't work, then right click the project, AndroidTools->Fix project properties.
Upvotes: 0