Robby Smet Robby Smet - 1 year ago 30
Android Question

Text on spinner is white on a white background

The text on my spinners is white, and I have no idea why.

enter image description here

This is my xml, nothing special

android:layout_weight="1" />

And my code

dateSpinner = (Spinner) findViewById(;
selectedDate = calendar.getTime();
List<String> list = new ArrayList<String>();
dateAdapter = new ArrayAdapter<String>(mContext,
android.R.layout.simple_spinner_item, list);

What could be the reason that my text is displayed in white?

I've found the reason, I replaced the mContext parameter which was set in my onCreate.

mContext = getApplicationContext();

Now I use d

ateAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);

and it works.


I have same problem and have found the answer. You dont use application context, instead, just use getActivity() (if you are in fragment) or this (if you are in activity), it will work

 dateAdapter = new ArrayAdapter<String>(**this**,
        android.R.layout.simple_spinner_item, list);