Я сделал это так:
int itemColor[] = new int[]{Color.rgb(188,108,218),
Color.rgb(88,18,218),
Color.rgb(18,108,28),
Color.rgb(18,108,118),
Color.rgb(218,88,218),
Color.rgb(138,108,118)};
...
final Spinner spinner = new Spinner(context);
String[] colors = new String[]{"[1]", "[2]", "[3]", "[4]", "[5]", "[6]"};
final List<String> colorsList = new ArrayList<>(Arrays.asList(colors));
final ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, colorsList)
{
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) super.getDropDownView(position, convertView, parent);
view.setBackgroundColor(itemColor[position]);
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
spinner.setAdapter(spinnerArrayAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
((TextView) parent.getChildAt(0)).setBackgroundColor(itemColor[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});