暗模式下的 Android Spinner 文本颜色

问题描述


我即将在我的 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" 设置它会起作用,但如果我以编程方式设置它则不起作用?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)