请帮我改变微调器的文字颜色。
答案 0 :(得分:5)
试试这个:
Spinner spinner = (Spinner)findViewById(R.id.my_spinner);
TextView tv = (TextView) spinner.getSelectedView();
tv.setTextColor(Color.BLACK);
否则在spinner_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="wrap_content"
android:textSize="20dip"
android:gravity="left"
android:textColor="#FF0000"
android:padding="5dip"
/>
答案 1 :(得分:5)
试试这个
<强> 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)
{
}
});