I'm trying to show a Toast when the user clicks on the Play button. But makeText
is red in my code, and it won't run. Where am I turning wrong?
Here is the Java code:
// Find the View that shows the play_a button
ImageView play_a = findViewById(R.id.play_a);
// Set a click listener on that View
play_a.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when play_a is clicked on.
Toast.makeText(this, "Sorry, Play doesn't work", Toast.LENGTH_LONG).show();
});
Is the problem that I need to override setOnClickListener
?