I have custom ArrayAdapter for spinners and need to change text color of items in dropdown. Code seems to be ok, but somehow it doesn't work.
public class CustomRadioArrayAdapter<T> extends ArrayAdapter<T> {
public CustomRadioArrayAdapter(Context context, T[] data) {
super(context, android.R.layout.simple_spinner_item, data);
this.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
public CustomRadioArrayAdapter(Context context, List<T> data) {
super(context, android.R.layout.simple_spinner_item, data);
this.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
if (view != null && view instanceof CheckedTextView) {
((CheckedTextView) view).setCheckMarkDrawable(R.drawable.radio);
((CheckedTextView) view).setTextColor(Color.rgb(255, 0, 255));
}
view.setBackgroundResource(R.drawable.spinback);
return view;
}
}
UPD I figured out that this code is not working on Android 4.0.4 on Lenovo, while on Android 4.0.3 HTC everything is displayed the right way.