android - 如何更改 Spinner 的文本颜色

标签 android spinner

<分区>

请帮助我更改微调器的文本颜色。

最佳答案

试试这个

custom_spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="top"
    android:singleLine="true"
    android:textColor="@color/iphone_text" />

在 Java 代码中

Spinner spnCategory= (Spinner)findViewById(R.id.my_spinner);

..

ArrayAdapter<String> adptSpnCategory = new ArrayAdapter<String>this,R.layout.custom_spinner_item, alCategoryName);
adptSpnCategory.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnCategory.setAdapter(adptSpnCategory);
spnCategory.setOnItemSelectedListener(new OnItemSelectedListener() 
{
 public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
 {
 }
 public void onNothingSelected(AdapterView<?> arg0) 
 {
 }
});

关于android - 如何更改 Spinner 的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14833714/

相关文章:

android,访问只是为了更新SDK

java - org.apache.http.client.ClientProtocolException异常

android - 如何将计时器实现为 fragment 内的自动图像幻灯片?

android - 在横向模式下将 View 伪造为纵向

java - 选择另一个微调器后更新微调器

android - 更改微调器启动图标

java - 为什么我的文字没有出现在微调器的 ImageView 中?

android - 如何从自身中删除 fragment

android - 如何将多个微调器值重置为默认值

JavaFX 微调器 : "Spinner cannot be resolved to a type"