How to disable an item in a Spinner

Viewed 35199

Is it possible to display particular entries in a Spinner list as disabled?

I.e., I want to always display a spinner with four entries (North, South, East, and West, say), but I want to be able to disable any one of these so that is appears greyed out and not selectable.

Is this possible, or will I have to recreate the list each time, leaving out the invalid entries?

5 Answers
class SpinnerAdapter(context: Context, resource: Int, list: ArrayList<String>)
    : ArrayAdapter<String>(context, resource, list) {

        override fun isEnabled(position: Int): Boolean {
            // select position to disable 
            return position != 0
        }

}
Related