FileDocCategorySizeDatePackage
TintSpinner.javaAPI DocAndroid 5.1 API2696Thu Mar 12 22:22:56 GMT 2015android.support.v7.internal.widget

TintSpinner

public class TintSpinner extends android.widget.Spinner
An tint aware {@link android.widget.Spinner}.
hide

Fields Summary
private static final int[]
TINT_ATTRS
Constructors Summary
public TintSpinner(android.content.Context context)


       
        this(context, null);
    
public TintSpinner(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, android.R.attr.spinnerStyle);
    
public TintSpinner(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        super(context, attrs, defStyleAttr);

        TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, TINT_ATTRS,
                defStyleAttr, 0);
        setBackgroundDrawable(a.getDrawable(0));

        if (a.hasValue(1)) {
            final Drawable background = a.getDrawable(1);
            if (Build.VERSION.SDK_INT >= 16) {
                setPopupBackgroundDrawable(background);
            } else if (Build.VERSION.SDK_INT >= 11) {
                setPopupBackgroundDrawableV11(this, background);
            }
        }

        a.recycle();
    
Methods Summary
private static voidsetPopupBackgroundDrawableV11(android.widget.Spinner view, android.graphics.drawable.Drawable background)

        try {
            Field popupField = Spinner.class.getDeclaredField("mPopup");
            popupField.setAccessible(true);

            Object popup = popupField.get(view);

            if (popup instanceof ListPopupWindow) {
                ((ListPopupWindow) popup).setBackgroundDrawable(background);
            }
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }