@@ -68,6 +68,7 @@ public class Spinner extends AbsSpinner implements OnClickListener {
6868 int mDropDownWidth ;
6969
7070 private int mGravity ;
71+ private boolean mDisableChildrenWhenDisabled ;
7172
7273 private Rect mTempRect = new Rect ();
7374
@@ -186,6 +187,9 @@ public Spinner(Context context, AttributeSet attrs, int defStyle, int mode) {
186187
187188 mPopup .setPromptText (a .getString (com .android .internal .R .styleable .Spinner_prompt ));
188189
190+ mDisableChildrenWhenDisabled = a .getBoolean (
191+ com .android .internal .R .styleable .Spinner_disableChildrenWhenDisabled , false );
192+
189193 a .recycle ();
190194
191195 // Base constructor can call setAdapter before we initialize mPopup.
@@ -196,6 +200,17 @@ public Spinner(Context context, AttributeSet attrs, int defStyle, int mode) {
196200 }
197201 }
198202
203+ @ Override
204+ public void setEnabled (boolean enabled ) {
205+ super .setEnabled (enabled );
206+ if (mDisableChildrenWhenDisabled ) {
207+ final int count = getChildCount ();
208+ for (int i = 0 ; i < count ; i ++) {
209+ getChildAt (i ).setEnabled (enabled );
210+ }
211+ }
212+ }
213+
199214 /**
200215 * Describes how the selected item view is positioned. Currently only the horizontal component
201216 * is used. The default is determined by the current theme.
@@ -398,6 +413,9 @@ private void setUpChild(View child) {
398413 addViewInLayout (child , 0 , lp );
399414
400415 child .setSelected (hasFocus ());
416+ if (mDisableChildrenWhenDisabled ) {
417+ child .setEnabled (isEnabled ());
418+ }
401419
402420 // Get measure specs
403421 int childHeightSpec = ViewGroup .getChildMeasureSpec (mHeightMeasureSpec ,
0 commit comments