In trying to complete the ImageButton challenge at the end of chapter 2, I get an error when I change the mNextButton and mPreviousButton. I’m not sure what the error said exactly as I somehow turned off the error message function and can’t figure out how to turn it back on. I changed the xml file from Button to ImageButton as it shows in the book. In QuizActivity.java, I changed
private Button mNextButton;
to:
private ImageButton mNextButton;
I then wrote:
mNextButton = (ImageButton)findViewById(R.id.next_button);
mNextButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
updateQuestion();
}
});
The error came at: (ImageButton)findViewById(R.id.next_button)
Isn’t this the correct way to cast the View returned into ImageButton to assign it to mNextButton?
I recommend that you play around with Logcat until you can see messages again. Try changing some of the filters in logcat, using the restart arrow (it’s green on the left). Restarting Android Studio.
Once Logcat is working again, the stacktrace will tell you what the problem is.
Your code looks OK to me. I’m guess that the view with the id: next_button
in your layout file is not an ImageButton. So, casting to an ImageButton is failing. That’s a guess though. The stacktrace can tell us what the problem actually is.
Yes that was the problem. I had the next_button in the layout file set to ImageView instead of ImageButton. This was causing the error.
As to the logcat, I searched everywhere for it to turn it back on. Couldn’t find it. I’m sure that’s going to be something I’ll need eventually. I accidentally turned it off by clicking on the red light bulb on the left side and clicking disable. I have no idea what kind of error message it was or where to find it to turn it back on.
What’s the red lightbulb? Can you share a screenshot?
Here’s an example of a red bulb… Although it was referring to red marks under the error mentioned above. Now those red marks under the words do not show, nor the red bulb for that particular error. As this picture shows, the bulb appears for other types of errors. If you have any idea where I might turn on this particular error message again, that would be great. Otherwise I’ll just plan on not making any errors.
I could just restore all default settings but I haven’t figured that out either.

Yea, I’m not sure where Android Studio stores those settings when you ask it to ignore a particular error. It could even be project specific rather than a setting on the IDE itself.
Hello, also in Android Studio, you can check File>Settings>Editor and open Editor tab that on the left.You can see Inspections.
Inspections include these error message.Maybe you can find a solution for your problem.