Android 我将一个片段转换为一个对话框,现在文本颜色已经改变

Android 我将一个片段转换为一个对话框,现在文本颜色已经改变,android,android-layout,android-fragments,android-preferences,android-dialog,Android,Android Layout,Android Fragments,Android Preferences,Android Dialog,这是我的第一个应用程序。我已经在一个活动中设置了一个首选项(带有一个片段),但我想将片段移动到一个对话框首选项。没问题,只是我的文字颜色变怪了。见图。文本应该是黑色,而不是白色和灰色。知道我做错了什么吗 (对不起,我知道这是一个相当草率的代码) 现在的样子: 我的xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.and

这是我的第一个应用程序。我已经在一个活动中设置了一个首选项(带有一个片段),但我想将片段移动到一个
对话框首选项
。没问题,只是我的文字颜色变怪了。见图。文本应该是黑色,而不是白色和灰色。知道我做错了什么吗

(对不起,我知道这是一个相当草率的代码)

现在的样子:

我的xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/relLay_dialog_semester_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin" >

    <TextView
        android:id="@+id/select_semester_prompt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/select_semester_prompt" />

    <LinearLayout
        android:id="@+id/linLayGradeSum"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/select_semester_prompt"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp" >

        <Spinner
            android:id="@+id/semester_spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:hint="@string/hint_editSemester" />

        <Spinner
            android:id="@+id/year_spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="4" />
    </LinearLayout>

    <TextView
        android:id="@+id/active_semesters_str"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/linLayGradeSum"
        android:layout_below="@+id/linLayGradeSum"
        android:text="@string/active_semester_str"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <LinearLayout
        android:id="@+id/active_semesters_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/active_semesters_str"
        android:layout_below="@+id/active_semesters_str"
        android:layout_marginTop="10dp"
        android:orientation="vertical" >


    </LinearLayout>

</RelativeLayout>
此外,正如Huy Tran所建议的那样,我可以通过为微调器文本制作自己的xml布局将其变为黑色。但是,我必须为每个微调器_项和微调器_下拉列表_项制作一个。见下文

ArrayAdapter<String> adapter_year = new ArrayAdapter<String>(this.getContext().getApplicationContext(),
                    R.layout.my_spinner_item, years);
            Spinner spinYear = (Spinner)view.findViewById(R.id.year_spinner);
            adapter_year.setDropDownViewResource(R.layout.my_spinner_dropdown_item);
ArrayAdapter\u year=新的ArrayAdapter(this.getContext().getApplicationContext(),
R.layout.my\u微调器项目,年);
微调器微调年=(微调器)视图.findViewById(R.id.year\u微调器);
适配器\u year.setDropDownViewResource(R.layout.my\u微调器\u下拉列表\u项);

我为什么要这么做?我不知道。此外,下拉项目现在每个都高出50%左右。我将其复制到自己的xml中,但呈现方式仍然不同。非常奇怪。

创建如下布局,并在
setDropDownViewResource
中使用该布局,而不是
android.R.layout.simple\u spinner\u dropdown\u item

res/layout
中创建我的微调器\u下拉列表\u item.xml

编辑:

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:textColor="@color/black"
    />

你能把你使用这个对话框的地方贴出来吗。你在某处使用黑暗主题吗?@Rod_Algonquin我更新了我的问题。我寻找黑暗主题的用法,但找不到任何参考资料。谢谢,这很有帮助。但是,我必须为
myspinner\u下拉列表\u项
资源和
myspinner\u项
资源执行此操作。此外,每个下拉项的垂直高度现在大约增加了50%。我不知道为什么,因为我的代码是安卓的源代码副本,只粘贴了文本颜色更改。
ArrayAdapter<String> adapter_year = new ArrayAdapter<String>(this.getContext().getApplicationContext(),
                    R.layout.my_spinner_item, years);
            Spinner spinYear = (Spinner)view.findViewById(R.id.year_spinner);
            adapter_year.setDropDownViewResource(R.layout.my_spinner_dropdown_item);
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:textColor="@color/black"
    />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
        style="?android:attr/spinnerItemStyle"
    android:singleLine="true"
    android:textColor="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee" />
setDropDownViewResource(R.layout.my_spinner_dropdown_item);