TintSpinnerpublic class TintSpinner extends android.widget.Spinner An tint aware {@link android.widget.Spinner}. |
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 void | setPopupBackgroundDrawableV11(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();
}
|
|