1

I'm new to android studio. I just added setOnItemSelectedListener for a Spinner and the background color of the code for listener turns brown (somehow like a selection):

enter image description here

What does this color mean? Is it normal or is it indicating a problem? And how can I make it go away because its really annoying.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171

2 Answers2

1

This is caused by the Android Studio trying to warn you that some method invocation may produce some exception (usually a NullPointerException). You can fix this by adding an if check for each thing like:

if(myThing != null){
    //do stuff
}

Or simply by adding before using myThing:

assert myThing != null;

Check this and maybe this question for further improving your insight on this.

Community
  • 1
  • 1
Vucko
  • 7,371
  • 2
  • 27
  • 45
0

If you want to change the theme you can do it by File->Settings->Editor->Colors & Fonts-> In scheme name select Default and apply to see the white background of the studio.

Dipali Shah
  • 3,742
  • 32
  • 47