I have imageView for play and stop and I have tried to implement OnClickListener. But the click event is not handled. Even if I try to start the application in debug mode then also I am not able to detect click event. What could be the error in this code ?
public class DetailActivity extends ActionBarActivity implements
OnClickListener {
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details_activity);
try {
mp = MediaPlayer.create(this, R.raw.baabaa);
mp.prepare();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.stop:
mp.stop();
break;
case R.id.play:
mp.start();
break;
default:
break;
}
}
}