I'm new to programming and have been racking my brain for the past couple of hours trying to resolve the issue. I know it's something stupid. I am trying to get each button to play a sound. Any help is greatly appreciated.
(ADDED "import android.view.View.OnClickListener;"
, TURNED MY PROBLEMS GREEN UNTIL I CLOSED IT OUT WITH ";" BUT THEN THE IMPORT GRAYED OUT.)
public class PocketParent extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final MediaPlayer stopMP = MediaPlayer.create(this, R.raw.btmg);
final MediaPlayer dropMP = MediaPlayer.create(this, R.raw.knock);
final MediaPlayer popMP = MediaPlayer.create(this, R.raw.oldsoulwr);
final MediaPlayer noMP = MediaPlayer.create(this, R.raw.smpr);
final MediaPlayer yeahMP = MediaPlayer.create(this, R.raw.upbeaty);
ImageButton playstop = (ImageButton) this.findViewById(R.id.imageButton);
ImageButton playdrop = (ImageButton) this.findViewById(R.id.imageButton2);
ImageButton playpop = (ImageButton) this.findViewById(R.id.imageButton3);
ImageButton playno = (ImageButton) this.findViewById(R.id.imageButton4);
ImageButton playyeah = (ImageButton) this.findViewById(R.id.imageButton5);
// (HERE IS WHERE MY PROBLEM LIES)
// *OnClickListener is abstract, cannot be instantiated.*
// (IT ALSO SAYS IT'S EXPECTING A "," OR " ' " RIGHT BEFORE "new",
// but that doesn't work either.)
playstop.setOnClickListener(new View.OnClickListener()
playdrop.setOnClickListener(new View.OnClickListener()
playpop.setOnClickListener(new View.OnClickListener()
playno.setOnClickListener(new View.OnClickListener()
playyeah.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stopMP.start();
dropMP.start();
popMP.start();
noMP.start();
yeahMP.start();
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
}
....
}
}