如何在选择字段之前和之后更改微调器文本颜色?
How to change spinner text color, before and after the field is selected?
我在我的页面中使用了微调器,我想更改微调器的文本颜色text.Before选择了一个字段,它必须是一种颜色,并且文本颜色在选择文本后应该不同.
这是我的代码
<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() 方法中改变颜色:
((TextView)parentView.getChildAt(0)).setTextColor(Color.rgb(249, 249, 249));
我在我的页面中使用了微调器,我想更改微调器的文本颜色text.Before选择了一个字段,它必须是一种颜色,并且文本颜色在选择文本后应该不同.
这是我的代码
<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() 方法中改变颜色:
((TextView)parentView.getChildAt(0)).setTextColor(Color.rgb(249, 249, 249));