0

我即将在我的 Android 应用中实现深色主题。
我遇到的问题是我选择的微调器的文本颜色。-> 它是“黑色”作为背景...
如果我以编程方式设置微调器的值,则会出现此问题。如果我在 xml 中设置它们,文本的颜色是白色的,正如预期的那样。
如果我打开微调器,可选项目的文本颜色是正确的。
在明亮模式下,文本以背景色和白色背景显示
这是我的代码:
    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;
        }
    };

我错过了什么?如果我通过微调器 xml 设置它为什么会起作用android:entries="@array/array_name",但如果我以编程方式设置它就不行?

4

0 回答 0