Class AbsSpinner

All Implemented Interfaces:
Drawable.Callback, ViewManager, ViewParent
Direct Known Subclasses:
Spinner

public abstract class AbsSpinner extends AdapterView<SpinnerAdapter>
An abstract base class for spinner widgets.
  • Method Details

    • setAdapter

      public void setAdapter(@Nullable SpinnerAdapter adapter)
      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.
      Specified by:
      setAdapter in class AdapterView<SpinnerAdapter>
      Parameters:
      adapter - The SpinnerAdapter to use for this Spinner
    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Figure out the dimensions of this Spinner. The width comes from the widthMeasureSpec as Spinners can't have their width set to UNSPECIFIED. The height is based on the height of the selected item plus padding.
      Overrides:
      onMeasure in class View
      Parameters:
      widthMeasureSpec - width measure specification imposed by the parent MeasureSpec
      heightMeasureSpec - height measure specification imposed by the parent MeasureSpec
      See Also:
    • generateDefaultLayoutParams

      @Nonnull protected ViewGroup.LayoutParams generateDefaultLayoutParams()
      Description copied from class: ViewGroup
      Returns a set of default layout parameters. These parameters are requested when the View passed to ViewGroup.addView(View) has no layout parameters already set. If null is returned, an exception is thrown from addView.
      Overrides:
      generateDefaultLayoutParams in class ViewGroup
      Returns:
      a set of default layout parameters
    • setSelection

      public void setSelection(int position, boolean animate)
      Jump directly to a specific item in the adapter data.
    • setSelection

      public void setSelection(int position)
      Description copied from class: AdapterView
      Sets the currently selected item. To support accessibility subclasses that override this method must invoke the overridden super method first.
      Specified by:
      setSelection in class AdapterView<SpinnerAdapter>
      Parameters:
      position - Index (starting at 0) of the data item to be selected.
    • getSelectedView

      public View getSelectedView()
      Specified by:
      getSelectedView in class AdapterView<SpinnerAdapter>
      Returns:
      The view corresponding to the currently selected item, or null if nothing is selected
    • requestLayout

      public void requestLayout()
      Override to prevent spamming ourselves with layout requests as we place views
      Specified by:
      requestLayout in interface ViewParent
      Overrides:
      requestLayout in class View
      See Also:
    • getAdapter

      public SpinnerAdapter getAdapter()
      Description copied from class: AdapterView
      Returns the adapter currently associated with this widget.
      Specified by:
      getAdapter in class AdapterView<SpinnerAdapter>
      Returns:
      The adapter used to provide this view's content.
    • getCount

      public int getCount()
      Overrides:
      getCount in class AdapterView<SpinnerAdapter>
      Returns:
      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.)
    • pointToPosition

      public int pointToPosition(int x, int y)
      Maps a point to a position in the list.
      Parameters:
      x - X in local coordinate
      y - Y in local coordinate
      Returns:
      The position of the item which contains the specified point, or AdapterView.INVALID_POSITION if the point does not intersect an item.