Android 12 Developer Preview is here! Try it out, and give us your feedback!

AppCompatSpinner

public class AppCompatSpinner
extends Spinner implements TintableBackgroundView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AdapterView<android.widget.SpinnerAdapter>
         ↳ android.widget.AbsSpinner
           ↳ android.widget.Spinner
             ↳ androidx.appcompat.widget.AppCompatSpinner


A Spinner which supports compatible features on older versions of the platform, including:

This will automatically be used when you use Spinner in your layouts. You should only need to manually use this class when writing custom views.

Summary

Inherited constants

Inherited fields

Public constructors

AppCompatSpinner(Context context)

Construct a new spinner with the given context's theme.

AppCompatSpinner(Context context, int mode)

Construct a new spinner with the given context's theme and the supplied mode of displaying choices.

AppCompatSpinner(Context context, AttributeSet attrs)

Construct a new spinner with the given context's theme and the supplied attribute set.

AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr)

Construct a new spinner with the given context's theme, the supplied attribute set, and default style attribute.

AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode)

Construct a new spinner with the given context's theme, the supplied attribute set, and default style.

AppCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode, Resources.Theme popupTheme)

Constructs a new spinner with the given context's theme, the supplied attribute set, default styles, popup mode (one of Spinner.MODE_DIALOG or Spinner.MODE_DROPDOWN), and the context against which the popup should be inflated.

Public methods

int getDropDownHorizontalOffset()

Get the configured horizontal offset in pixels for the spinner's popup window of choices.

int getDropDownVerticalOffset()
int getDropDownWidth()
Drawable getPopupBackground()
Context getPopupContext()
CharSequence getPrompt()
void onRestoreInstanceState(Parcelable state)
Parcelable onSaveInstanceState()
boolean onTouchEvent(MotionEvent event)
boolean performClick()
void setAdapter(SpinnerAdapter adapter)
void setBackgroundDrawable(Drawable background)
void setBackgroundResource(int resId)
void setDropDownHorizontalOffset(int pixels)
void setDropDownVerticalOffset(int pixels)
void setDropDownWidth(int pixels)
void setPopupBackgroundDrawable(Drawable background)
void setPopupBackgroundResource(int resId)
void setPrompt(CharSequence prompt)

Protected methods

void drawableStateChanged()
void onDetachedFromWindow()
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods