by Sondar » Wed Aug 05, 2009 7:02 pm
I think I fixed this problem but a new one has appeared:
In this code:
package hand.gun.app;
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class HandGunApp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button GunButton = (Button)findViewById(R.id.GunButton);
GunButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
MediaPlayer mp = MediaPlayer.create
(MusicPlayer.this, R.raw.gunshot);
mp.prepare();
mp.start();
// i.e. react on the end of the music-file:
mp.setOnCompletionListener(new OnCompletionListener(){
// @Override
public void onCompletion(MediaPlayer arg0) {
// File has ended !!!
}
});
}
});
}
}
It says on the line:
(MusicPlayer.this, R.raw.gunshot);
Music Player cannot be resolved to a type and R.raw cannot be resolved.
Any Ideas?