spinner = (Spinner) view.findViewById(R.id.crow_search_select);
ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(App.activity,
R.array.search_orders,
R.layout.spinner_text_color);// android.R.layout.simple_spinner_item
arrayAdapter.setDropDownViewResource(R.layout.crowd_spinner_dropdown_item);
spinner.setAdapter(arrayAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
searchOrderType = position;
beginSearch();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
这里ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(App.activity,
R.array.search_orders,
R.layout.spinner_text_color);
R.layout.spinner_text_color是自定义的textview
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textColor="#ffffff"/>
是根据系统的修改添加了textcolor属性之后的
这样就可以修改spinner的显示文字的颜色了
ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(App.activity,
R.array.search_orders,
R.layout.spinner_text_color);// android.R.layout.simple_spinner_item
arrayAdapter.setDropDownViewResource(R.layout.crowd_spinner_dropdown_item);
spinner.setAdapter(arrayAdapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
searchOrderType = position;
beginSearch();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
这里ArrayAdapter<CharSequence> arrayAdapter = ArrayAdapter.createFromResource(App.activity,
R.array.search_orders,
R.layout.spinner_text_color);
R.layout.spinner_text_color是自定义的textview
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textColor="#ffffff"/>
是根据系统的修改添加了textcolor属性之后的
这样就可以修改spinner的显示文字的颜色了