Added in API level 1

AbsSpinner


abstract class AbsSpinner : AdapterView<SpinnerAdapter!>
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.AdapterView<android.widget.SpinnerAdapter>
   ↳ android.widget.AbsSpinner

An abstract base class for spinner widgets. SDK users will probably not need to use this class.

Summary

XML attributes
android:entries Reference to an array resource that will populate the Spinner.
Inherited XML attributes
Inherited constants
Public constructors
AbsSpinner(context: Context!)

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

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

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

Public methods
open Unit

Automatically fills the content of this view with the value.

open CharSequence!

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

open SpinnerAdapter!

Returns the adapter currently associated with this widget.

open Int

Describes the autofill type of this view, so an android.service.autofill.AutofillService can create the proper AutofillValue when autofilling the view.

open AutofillValue?

Gets the View's current autofill value.

open Int

open View!

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 Int

Maps a point to a position in the list.

open Unit

Override to prevent spamming ourselves with layout requests as we place views

open Unit

The Adapter is used to provide the data which backs this Spinner.

open Unit
setSelection(position: Int)

Sets the currently selected item.

open Unit
setSelection(position: Int, animate: Boolean)

Jump directly to a specific item in the adapter data.

Protected methods
open Unit

Override to prevent thawing of any views created by the adapter.

open ViewGroup.LayoutParams!

Returns a set of default layout parameters.

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

Inherited functions
Inherited properties

XML attributes

android:entries

android:entries
Reference to an array resource that will populate the Spinner. For static content, this is simpler than populating the Spinner programmatically.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Public constructors

AbsSpinner

Added in API level 1
AbsSpinner(context: Context!)

AbsSpinner

Added in API level 1
AbsSpinner(
    context: Context!,
    attrs: AttributeSet!)

AbsSpinner

Added in API level 1
AbsSpinner(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

AbsSpinner

Added in API level 21
AbsSpinner(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

autofill

Added in API level 26
open fun autofill(value: AutofillValue!): Unit

Automatically fills the content of this view with the value.

Views support the Autofill Framework mainly by:

  • Providing the metadata defining what the view means and how it can be autofilled.
  • Implementing the methods that autofill the view.

onProvideAutofillStructure(android.view.ViewStructure,int) is responsible for the former, this method is responsible for latter.

This method does nothing by default, but when overridden it typically:

  1. Checks if the provided value matches the expected type (which is defined by getAutofillType()).
  2. Checks if the view is editable - if it isn't, it should return right away.
  3. Call the proper getter method on AutofillValue to fetch the actual value.
  4. Pass the actual value to the equivalent setter in the view.

For example, a text-field view could implement the method this way:

@Override
  public void autofill(AutofillValue value) {
    if (!value.isText() || !this.isEditable()) {
       return;
    }
    CharSequence text = value.getTextValue();
    if (text != null) {
      this.setText(text);
    }
  }
  

If the value is updated asynchronously, the next call to AutofillManager.notifyValueChanged(View) must happen after the value was changed to the autofilled value. If not, the view will not be considered autofilled.

Note: After this method is called, the value returned by getAutofillValue() must be equal to the value passed to it, otherwise the view will not be highlighted as autofilled.

Parameters
value AutofillValue!: value to be autofilled.

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

getAdapter

Added in API level 1
open fun getAdapter(): SpinnerAdapter!

Returns the adapter currently associated with this widget.

Return
SpinnerAdapter! The adapter used to provide this view's content.

getAutofillType

Added in API level 26
open fun getAutofillType(): Int

Describes the autofill type of this view, so an android.service.autofill.AutofillService can create the proper AutofillValue when autofilling the view.

By default returns AUTOFILL_TYPE_NONE, but views should override it to properly support the Autofill Framework.

Return
Int Value is one of the following:

getAutofillValue

Added in API level 26
open fun getAutofillValue(): AutofillValue?

Gets the View's current autofill value.

By default returns null, but subclasses should override it and return an appropriate value to properly support the Autofill Framework.

getCount

Added in API level 1
open fun getCount(): Int
Return
Int The number of items owned by the Adapter associated with this AdapterView. (This is the number of data items, which may be larger than the number of visible views.)

getSelectedView

Added in API level 1
open fun getSelectedView(): View!
Return
View! The view corresponding to the currently selected item, or null if nothing is selected

onRestoreInstanceState

Added in API level 1
open fun onRestoreInstanceState(state: Parcelable!): Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
If you override this method you must call through to the superclass implementation.

Parameters
state Parcelable!: The frozen state that had previously been returned by onSaveInstanceState.

onSaveInstanceState

Added in API level 1
open fun onSaveInstanceState(): 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. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
If you override this method you must call through to the superclass implementation.

Return
Parcelable? Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.

pointToPosition

Added in API level 1
open fun pointToPosition(
    x: Int,
    y: Int
): Int

Maps a point to a position in the list.

Parameters
x Int: X in local coordinate
y Int: Y in local coordinate
Return
Int The position of the item which contains the specified point, or INVALID_POSITION if the point does not intersect an item.

requestLayout

Added in API level 1
open fun requestLayout(): Unit

Override to prevent spamming ourselves with layout requests as we place views

setAdapter

Added in API level 1
open fun setAdapter(adapter: SpinnerAdapter!): Unit

The Adapter is used to provide the data which backs this Spinner. It also provides methods to transform spinner items based on their position relative to the selected item.

Parameters
adapter SpinnerAdapter!: The SpinnerAdapter to use for this Spinner

setSelection

Added in API level 1
open fun setSelection(position: Int): Unit

Sets the currently selected item. To support accessibility subclasses that override this method must invoke the overridden super method first.

Parameters
position Int: Index (starting at 0) of the data item to be selected.

setSelection

Added in API level 1
open fun setSelection(
    position: Int,
    animate: Boolean
): Unit

Jump directly to a specific item in the adapter data.

Protected methods

dispatchRestoreInstanceState

Added in API level 1
protected open fun dispatchRestoreInstanceState(container: SparseArray<Parcelable!>!): Unit

Override to prevent thawing of any views created by the adapter.

Parameters
container SparseArray<Parcelable!>!: The SparseArray which holds previously saved state.

generateDefaultLayoutParams

Added in API level 1
protected open fun generateDefaultLayoutParams(): ViewGroup.LayoutParams!

Returns a set of default layout parameters. These parameters are requested when the View passed to addView(android.view.View) has no layout parameters already set. If null is returned, an exception is thrown from addView.

Return
ViewGroup.LayoutParams! a set of default layout parameters or null

onMeasure

Added in API level 1
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit
Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.