Java Can';无法在微调器上更改文本颜色

Java Can';无法在微调器上更改文本颜色,java,android,android-spinner,android-styles,Java,Android,Android Spinner,Android Styles,我已经尝试了很多其他的答案,所以,它们似乎都不适合我。我不确定我做错了什么 以下是我的xml: <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/product_category_spinner" android:theme="@style/AppartmentBlue" /> 下面是我的Java(它

我已经尝试了很多其他的答案,所以,它们似乎都不适合我。我不确定我做错了什么

以下是我的xml:

<Spinner
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/product_category_spinner"
    android:theme="@style/AppartmentBlue" />

下面是我的Java(它是一个DialogFragment扩展类):

@覆盖
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//为该碎片膨胀布局
视图v=充气机。充气(R.layout.fragment\u product\u对话框,容器,错误);
微调器productCategory=(微调器)v.findViewById(R.id.product\u category\u微调器);
阵列适配器旋转适配器=
新的ArrayAdapter(getActivity().getApplicationContext(),
android.R.layout.simple\u微调器\u下拉菜单\u项,
getResources().getStringArray(R.array.category_数组));
spinnerAdapter.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
productCategory.setAdapter(spinnerAdapter);
//可设置可取消(假);
返回v;
}
问题是,文本是白色的,非常亮的灰色。默认情况下是这样的,如果它出现在黑色前景中,我就不需要触摸它了。它为什么要这样做?我的主题从
theme.Holo.Light.DarkActionBar
扩展而来

我不想在运行时设置它,我会有很多微调器,我希望它在整个应用程序中都是全局的,并且我可以选择添加以后的主题。

我希望这有助于:

我的纺纱工:

<Spinner
    android:id="@+id/spinner_cat"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingBottom="0dp"
    android:paddingTop="0dp"
    android:layout_marginStart="@dimen/left_margin_large"
    android:layout_marginLeft="@dimen/left_margin_large"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"/>

设置适配器:

private final int _singleItemRes = R.layout.simple_spinner_item;
private final int _dropdownRes = R.layout.simple_spinner_dropdown_item;

ArrayAdapter<String> adapter = new ArrayAdapter<String>(_handler.getContext(), _singleItemRes, getTitles());
adapter.setDropDownViewResource(_dropdownRes);
private final int\u singleItemRes=R.layout.simple\u spinner\u item;
私有最终整数_dropdownRes=R.layout.simple_微调器_dropdownRes\u项目;
ArrayAdapter=新的ArrayAdapter(_handler.getContext(),_singleItemRes,getTitles());
adapter.setDropDownViewResource(_dropdownRes);
simple_spinner_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:textColor="@color/actionbar_text"
    android:textSize="20sp"
    android:textStyle="normal"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@color/primary_dark"
    android:ellipsize="marquee"
    android:layout_centerVertical="true"
    android:singleLine="true"
    android:paddingRight="@dimen/left_margin_small"
    android:paddingLeft="@dimen/left_margin_small"
    android:textColor="@color/actionbar_text"/>

simple_spinner_dropdown_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:textColor="@color/actionbar_text"
    android:textSize="20sp"
    android:textStyle="normal"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@color/primary_dark"
    android:ellipsize="marquee"
    android:layout_centerVertical="true"
    android:singleLine="true"
    android:paddingRight="@dimen/left_margin_small"
    android:paddingLeft="@dimen/left_margin_small"
    android:textColor="@color/actionbar_text"/>


如果我在答案中遗漏了什么,请告诉我,我会将其添加进去。

我将其更改为使用我自己的风格,效果很好!遗憾的是,我需要制作一个纯文本视图的资源布局,只是为了在全球范围内更改颜色。很高兴它能工作。我同意这很烦人,而且谷歌没有很好地考虑到这一点。