Android 如何在选择字段之前和之后更改微调器文本颜色?

Android 如何在选择字段之前和之后更改微调器文本颜色?,android,spinner,android-spinner,Android,Spinner,Android Spinner,我已在页面中使用微调器,我想更改微调器文本的文本颜色。在选择字段之前,它必须为一种颜色,并且在选择文本后,文本颜色应不同 这是我的代码 <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <Spinner android:layout_width="match_parent"

我已在页面中使用微调器,我想更改微调器文本的文本颜色。在选择字段之前,它必须为一种颜色,并且在选择文本后,文本颜色应不同

这是我的代码

       <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

         <Spinner android:layout_width="match_parent"
            android:layout_height="60dp"
            android:id="@+id/spstate"
            android:prompt="@string/state_prompt"
            android:entries="@array/state_arrays"
            android:popupBackground="#cccccc">
        </Spinner>

     </LinearLayout>

创建微调器时,设置XML中的默认文本颜色:

android:textColor="#FF0000"
然后在onItemSelected()方法中更改颜色:


创建微调器时,设置XML中的默认文本颜色:

android:textColor="#FF0000"
然后在onItemSelected()方法中更改颜色:


我不知道微调器文本的更改,但您可以创建一个自定义微调器,在其中可以自定义任何需要的内容。如果你想试试,我可以帮你。:)我不知道微调器文本的更改,但您可以创建一个自定义微调器,在其中可以自定义任何需要的内容。如果你想试试,我可以帮你。:)您好,我尝试了这个,但我从服务器动态获取数据,因此有其他方法更改颜色。您好,我尝试了这个,但我从服务器动态获取数据,因此有其他方法更改颜色。