Class DropDownListView

All Implemented Interfaces:
Drawable.Callback, ViewManager, ViewParent, Filter.FilterListener
Direct Known Subclasses:
MenuPopupWindow.MenuDropDownListView

@Internal public class DropDownListView extends ListView
Wrapper class for a ListView. This wrapper can hijack the focus to make sure the list uses the appropriate drawables and states when displayed on screen within a drop down. The focus is never actually passed to the drop down in this mode; the list only looks focused.
  • Constructor Details

    • DropDownListView

      public DropDownListView(Context context, boolean hijackFocus)
      Creates a new list view wrapper.
  • Method Details

    • onTouchEvent

      public boolean onTouchEvent(@Nonnull MotionEvent ev)
      Description copied from class: View
      Implement this method to handle touch screen motion events.

      If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling View.performClick(). This will ensure consistent system behavior.

      Overrides:
      onTouchEvent in class AbsListView
      Parameters:
      ev - the touch event
      Returns:
      true if the event was handled by the view, false otherwise
    • onHoverEvent

      public boolean onHoverEvent(@Nonnull MotionEvent ev)
      Description copied from class: View
      Implement this method to handle hover events.

      This method is called whenever a pointer is hovering into, over, or out of the bounds of a view and the view is not currently being touched. Hover events are represented as pointer events with action MotionEvent.ACTION_HOVER_ENTER, MotionEvent.ACTION_HOVER_MOVE, or MotionEvent.ACTION_HOVER_EXIT.

      • The view receives a hover event with action MotionEvent.ACTION_HOVER_ENTER when the pointer enters the bounds of the view.
      • The view receives a hover event with action MotionEvent.ACTION_HOVER_MOVE when the pointer has already entered the bounds of the view and has moved.
      • The view receives a hover event with action MotionEvent.ACTION_HOVER_EXIT when the pointer has exited the bounds of the view or when the pointer is about to go down due to a button click, tap, or similar user action that causes the view to be touched.

      The view should implement this method to return true to indicate that it is handling the hover event, such as by changing its drawable state.

      The default implementation calls View.setHovered(boolean) to update the hovered state of the view when a hover enter or hover exit event is received, if the view is enabled and is clickable. The default implementation also sends hover accessibility events.

      Overrides:
      onHoverEvent in class View
      Parameters:
      ev - The motion event that describes the hover.
      Returns:
      True if the view handled the hover event.
      See Also:
    • drawableStateChanged

      protected void drawableStateChanged()
      Description copied from class: View
      This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

      If the View has a StateListAnimator, it will also be called to run necessary state change animations.

      Be sure to call through to the superclass when overriding this function.

      Overrides:
      drawableStateChanged in class AbsListView
      See Also:
    • onForwardedEvent

      public boolean onForwardedEvent(@Nonnull MotionEvent event)
      Handles forwarded events.
      Returns:
      whether the event was handled
    • setListSelectionHidden

      public void setListSelectionHidden(boolean hideListSelection)
      Sets whether the list selection is hidden, as part of a workaround for a touch mode issue (see the declaration for mListSelectionHidden).
      Parameters:
      hideListSelection - true to hide list selection, false to show
    • isInTouchMode

      public boolean isInTouchMode()
      Description copied from class: View
      Returns whether the device is currently in touch mode. Touch mode is entered once the user begins interacting with the device by touch, and affects various things like whether focus is always visible to the user.
      Overrides:
      isInTouchMode in class View
      Returns:
      Whether the device is in touch mode.
    • hasWindowFocus

      public boolean hasWindowFocus()
      Returns the focus state in the drop down.
      Overrides:
      hasWindowFocus in class View
      Returns:
      true always if hijacking focus
    • isFocused

      public boolean isFocused()
      Returns the focus state in the drop down.
      Overrides:
      isFocused in class View
      Returns:
      true always if hijacking focus
    • hasFocus

      public boolean hasFocus()
      Returns the focus state in the drop down.
      Overrides:
      hasFocus in class ViewGroup
      Returns:
      true always if hijacking focus