Added in API level 1

Spinner


open class Spinner : AbsSpinner, DialogInterface.OnClickListener
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.AdapterView<android.widget.SpinnerAdapter>
   ↳ android.widget.AbsSpinner
   ↳ android.widget.Spinner

A view that displays one child at a time and lets the user pick among them. The items in the Spinner come from the Adapter associated with this view.

See the Spinners guide.

Summary

XML attributes
android:dropDownHorizontalOffset Amount of pixels by which the drop down should be offset horizontally.
android:dropDownSelector List selector to use for spinnerMode="dropdown" display.
android:dropDownVerticalOffset Amount of pixels by which the drop down should be offset vertically.
android:dropDownWidth Width of the dropdown in spinnerMode="dropdown".
android:gravity Gravity setting for positioning the currently selected item.
android:popupBackground Background drawable to use for the dropdown in spinnerMode="dropdown".
android:prompt The prompt to display when the spinner's dialog is shown.
android:spinnerMode Display mode for spinner options.
Inherited XML attributes
Constants
static Int

Use a dialog window for selecting spinner options.

static Int

Use a dropdown anchored to the Spinner for selecting spinner options.

Inherited constants
Public constructors
Spinner(context: Context!)

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

Spinner(context: Context!, attrs: AttributeSet!)

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

Spinner(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

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

Spinner(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, mode: Int)

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

Spinner(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int, mode: Int)

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

Spinner(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int, mode: Int, popupTheme: Resources.Theme!)

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

Spinner(context: Context!, mode: Int)

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

Public methods
open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Int

Return the offset of the widget's text baseline from the widget's top boundary.

open Int

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

open Int

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

open Int

Get the configured width of the spinner's popup window of choices in pixels.

open Int

Describes how the selected item view is positioned.

open Drawable!

Get the background drawable for the spinner's popup window of choices.

open Context!

open CharSequence!

open Unit
onClick(dialog: DialogInterface!, which: Int)

This method will be invoked when a button in the dialog is clicked.

open PointerIcon!
onResolvePointerIcon(event: MotionEvent!, pointerIndex: Int)

Resolve the pointer icon that should be used for specified pointer in the motion event.

open Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState.

open Parcelable?

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.

open Boolean

Implement this method to handle pointer events.

open Boolean

Call this view's OnClickListener, if it is defined.

open Unit

Sets the SpinnerAdapter used to provide the data which backs this Spinner.

open Unit

Set a horizontal offset in pixels for the spinner's popup window of choices.

open Unit

Set a vertical offset in pixels for the spinner's popup window of choices.

open Unit

Set the width of the spinner's popup window of choices in pixels.

open Unit
setEnabled(enabled: Boolean)

Set the enabled state of this view.

open Unit
setGravity(gravity: Int)

Describes how the selected item view is positioned.

open Unit

A spinner does not support item click events.

open Unit

Set the background drawable for the spinner's popup window of choices.

open Unit

Set the background drawable for the spinner's popup window of choices.

open Unit

Sets the prompt to display when the dialog is shown.

open Unit
setPromptId(promptId: Int)

Sets the prompt to display when the dialog is shown.

Protected methods
open Unit

This is called when the view is detached from a window.

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Measure the view and its content to determine the measured width and the measured height.

Inherited functions