I'm about to implement the dark theme in my Android app.
The problem, I've got is the text color of my selected spinner. -> It is "Black" as the background...
This problem occurs if I set the values of the spinner programmatically. If I set them in the xml, the color of the text is white, as expected.
If I open the spinner, the text color of the selectable items is correctly whitt.
In the bright mode, the text is displayed with a back color and a white background
This is my code:
mSearchServiceFilterSpinner = findViewById(R.id.services);
ArrayAdapter<SearchService> mSessionDropdownAdapter = new ArrayAdapter<SearchService>(getBaseContext(), android.R.layout.simple_spinner_item, searchServices) { // searchServices is my ArrayList with the selectable items.
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
View v = super.getDropDownView(position, null, parent);
// If this is the selected item position
v.setBackgroundColor(searchServices.get(position).getColor()); // Not important for the question
return v;
}
};
What am I missing? Why does it work if I set it via the spinner xml android:entries="@array/array_name", but not if I set it programmatically?