AppCompatSpinner
class AppCompatSpinner : Spinner, TintableBackgroundView
| kotlin.Any | ||||||
| ↳ | android.view.View | |||||
| ↳ | android.view.ViewGroup | |||||
| ↳ | android.widget.AdapterView | |||||
| ↳ | android.widget.AbsSpinner | |||||
| ↳ | android.widget.Spinner | |||||
| ↳ | androidx.appcompat.widget.AppCompatSpinner |
A Spinner which supports compatible features on older versions of the platform, including:
- Allows dynamic tint of its background via the background tint methods in
androidx.core.view.ViewCompat. - Allows setting of the background tint using
buttonTintandbuttonTintMode. - Setting the popup theme using
popupTheme.
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
Public constructors |
|---|
AppCompatSpinner(context: Context)Construct a new spinner with the given context's theme. |
AppCompatSpinner(context: Context, attrs: AttributeSet?)Construct a new spinner with the given context's theme and the supplied attribute set. |
AppCompatSpinner(context: Context, mode: Int)Construct a new spinner with the given context's theme and the supplied mode of displaying choices. |
AppCompatSpinner(context: Context, attrs: AttributeSet?, defStyleAttr: Int)Construct a new spinner with the given context's theme, the supplied attribute set, and default style attribute. |
AppCompatSpinner(Construct a new spinner with the given context's theme, the supplied attribute set, and default style. |
AppCompatSpinner(Constructs a new spinner with the given context's theme, the supplied attribute set, default styles, popup mode (one of |
Public functions |
|
|---|---|
Int |
Get the configured horizontal offset in pixels for the spinner's popup window of choices. |
Int |
|
Int |
|
Drawable! |
|
Context! |
|
CharSequence! |
|
Unit |
onRestoreInstanceState(state: Parcelable!) |
Parcelable! |
|
Boolean |
onTouchEvent(event: MotionEvent!) |
Boolean |
|
Unit |
setAdapter(adapter: SpinnerAdapter!) |
Unit |
setBackgroundDrawable(background: Drawable?)This function is deprecated. |
Unit |
setBackgroundResource(resId: @DrawableRes Int) |
Unit |
setDropDownHorizontalOffset(pixels: Int) |
Unit |
setDropDownVerticalOffset(pixels: Int) |
Unit |
setDropDownWidth(pixels: Int) |
Unit |
setPopupBackgroundDrawable(background: Drawable!) |
Unit |
setPopupBackgroundResource(resId: @DrawableRes Int) |
Unit |
setPrompt(prompt: CharSequence!) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
AppCompatSpinner
AppCompatSpinner(context: Context)
Construct a new spinner with the given context's theme.
| Parameters | |
|---|---|
context: Context |
The Context the view is running in, through which it can access the current theme, resources, etc. |
AppCompatSpinner
AppCompatSpinner(context: Context, attrs: AttributeSet?)
Construct a new spinner with the given context's theme and the supplied attribute set.
| Parameters | |
|---|---|
context: Context |
The Context the view is running in, through which it can access the current theme, resources, etc. |
attrs: AttributeSet? |
The attributes of the XML tag that is inflating the view. |
AppCompatSpinner
AppCompatSpinner(context: Context, mode: Int)
Construct a new spinner with the given context's theme and the supplied mode of displaying choices. mode may be one of MODE_DIALOG or MODE_DROPDOWN.
| Parameters | |
|---|---|
context: Context |
The Context the view is running in, through which it can access the current theme, resources, etc. |
mode: Int |
Constant describing how the user will select choices from the spinner. |
| See also | |
|---|---|
MODE_DIALOG |
|
MODE_DROPDOWN |
AppCompatSpinner
AppCompatSpinner(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
Construct a new spinner with the given context's theme, the supplied attribute set, and default style attribute.
| Parameters | |
|---|---|
context: Context |
The Context the view is running in, through which it can access the current theme, resources, etc. |
attrs: AttributeSet? |
The attributes of the XML tag that is inflating the view. |
defStyleAttr: Int |
An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults. |
AppCompatSpinner
AppCompatSpinner(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
mode: Int
)
Construct a new spinner with the given context's theme, the supplied attribute set, and default style. mode may be one of MODE_DIALOG or MODE_DROPDOWN and determines how the user will select choices from the spinner.
| Parameters | |
|---|---|
context: Context |
The Context the view is running in, through which it can access the current theme, resources, etc. |
attrs: AttributeSet? |
The attributes of the XML tag that is inflating the view. |
defStyleAttr: Int |
An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults. |
mode: Int |
Constant describing how the user will select choices from the spinner. |
| See also | |
|---|---|
MODE_DIALOG |
|
MODE_DROPDOWN |
AppCompatSpinner
AppCompatSpinner(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
mode: Int,
popupTheme: Resources.Theme!
)
Constructs a new spinner with the given context's theme, the supplied attribute set, default styles, popup mode (one of MODE_DIALOG or MODE_DROPDOWN), and the context against which the popup should be inflated.
| Parameters | |
|---|---|
context: Context |
The context against which the view is inflated, which provides access to the current theme, resources, etc. |
attrs: AttributeSet? |
The attributes of the XML tag that is inflating the view. |
defStyleAttr: Int |
An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults. |
mode: Int |
Constant describing how the user will select choices from the spinner. |
popupTheme: Resources.Theme! |
The theme against which the dialog or dropdown popup should be inflated. May be |
| See also | |
|---|---|
MODE_DIALOG |
|
MODE_DROPDOWN |
Public functions
getDropDownHorizontalOffset
fun getDropDownHorizontalOffset(): Int
Get the configured horizontal offset in pixels for the spinner's popup window of choices. Only valid in MODE_DROPDOWN; other modes will return 0.
| Returns | |
|---|---|
Int |
Horizontal offset in pixels |
getPopupContext
fun getPopupContext(): Context!
| Returns | |
|---|---|
Context! |
the context used to inflate the Spinner's popup or dialog window |