Possible duplicate of How do I make a Spinner's "disabled" state look disabled?.
I tried the solution mentioned in the post, ie
((Spinner) spinner).getSelectedView().setEnabled(false);
spinner.setEnabled(false);
However getSelectedView() returns null. I also tried manually selecting an item and than calling getSelectedView but it still returns null.
Create a drawable selector in the res/drawable folder like this
custonspinner.xml
// You can give the drawable also instead of colors in the selector
In your spinner set the background resource like this
@JSPDeveloper01's answer didn't quite work for me (possibly either due to the order that I'm setting my adapter or due to the fact that I'm using a two custom spinner classes: the first class extends the LinearLayout class; the second extends the Spinner class). The keys are invalidating the old object in the setEnabled function and setting the color in the onDraw function.
Inside both of those custom spinner classes, I have a special setEnabled function like this, invalidating the old view:
I also override the onDraw function in my each custom spinner class (using part of JSPDeveloper01's answer):
One way to do this is to write your own SpinnerAdapter (e.g. an ArrayAdapter) and then override the getView() method. Usually that method inflates the android.R.layout.simple_spinner_item layout and binds the TextView to your data (array in the case of ArrayAdapter). You could take that layout (copy it from your Android SDK folder) and create a disabled version and then do something like that:
The android.R.layout.simple_spinner_item looks like this:
I figured out the simplest way:
It won't change the color or font, just make it a little more transparent...