0

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?

2
  • pls fix your images Commented Feb 4, 2021 at 10:21
  • @FariborZ: It link to the pictures does not work. Neither drag and drop nor select. It worked the first time. I removed them now. Commented Feb 4, 2021 at 10:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.