Google 致力于为黑人社区推动种族平等。查看具体举措

AppCompatSpinner

open class AppCompatSpinner : Spinner, TintableBackgroundView
kotlin.Any
   ↳ 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

Public constructors
<init>(@NonNull context: Context)

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

<init>(@NonNull context: Context, mode: Int)

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

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

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

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int)

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

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int, mode: Int)

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

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?, defStyleAttr: Int, mode: Int, popupTheme: 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.

Public methods
open Int

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

open Int

open Int

open Drawable!

open Context!

open CharSequence!

open Unit

open Parcelable?

open Boolean

open Boolean

open Unit

open Unit
setBackgroundDrawable(@Nullable background: Drawable?)

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit

open Unit

open Unit

open Unit

open Unit
setPopupBackgroundResource(@DrawableRes resId: Int)

open Unit

Protected methods
open Unit

open Unit

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

Public constructors

<init>

AppCompatSpinner(@NonNull 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.

<init>

AppCompatSpinner(
    @NonNull 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.

<init>

AppCompatSpinner(
    @NonNull context: Context,
    @Nullable 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.

<init>

AppCompatSpinner(
    @NonNull context: Context,
    @Nullable 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.

<init>

AppCompatSpinner(
    @NonNull context: Context,
    @Nullable 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.

<init>

AppCompatSpinner(
    @NonNull context: Context,
    @Nullable attrs: