Package net.xpece.android.support.widget
Class XpListPopupWindow
- java.lang.Object
-
- net.xpece.android.support.widget.XpListPopupWindow
-
- All Implemented Interfaces:
androidx.appcompat.view.menu.ShowableListMenu
public class XpListPopupWindow extends java.lang.Object- See Also:
ListPopupWindow,ListPopupWindow
-
-
Field Summary
Fields Modifier and Type Field Description static intINPUT_METHOD_FROM_FOCUSABLEMode forsetInputMethodMode(int): the requirements for the input method should be based on the focusability of the popup.static intINPUT_METHOD_NEEDEDMode forsetInputMethodMode(int): this popup always needs to work with an input method, regardless of whether it is focusable.static intINPUT_METHOD_NOT_NEEDEDMode forsetInputMethodMode(int): this popup never needs to work with an input method, regardless of whether it is focusable.static intMATCH_PARENTstatic intMAX_WIDTH_FIT_ANCHORPopup menu width is limited by anchor width.static intMAX_WIDTH_FIT_SCREENPopup menu width is limited by screen width.static intPOSITION_PROMPT_ABOVEThe provided prompt view should appear above list content.static intPOSITION_PROMPT_BELOWThe provided prompt view should appear below list content.static intPREFERREDDeprecated.static intWIDTH_MATCH_CONSTRAINTPopup menu width is only limited bymaxWidth.static intWIDTH_WRAP_CONTENTPopup menu width is * at least as wide as its content, * limited bymaxWidth.static intWIDTH_WRAP_CONTENT_UNITPopup menu width is at least as wide as its content rounded up to a multiple ofwidthUnit, at least as wide aswidthUnit * 1.5, limited bymaxWidth.static intWRAP_CONTENT
-
Constructor Summary
Constructors Constructor Description XpListPopupWindow(android.content.Context context)XpListPopupWindow(android.content.Context context, android.util.AttributeSet attrs)XpListPopupWindow(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)XpListPopupWindow(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearListSelection()Clear any current list selection.android.view.View.OnTouchListenercreateDragToOpenListener(android.view.View src)Deprecated.This feature is currently not supported.voiddismiss()Dismiss the popup window.android.view.ViewgetAnchorView()Returns the view that will be used to anchor this popup.intgetAnimationStyle()Returns the animation style that will be used when the popup window is shown or dismissed.android.graphics.drawable.DrawablegetBackground()android.view.ViewgetBoundsView()intgetDropDownGravity()intgetHeight()intgetHorizontalOffset()intgetInputMethodMode()Return the current value insetInputMethodMode(int).android.widget.ListViewgetListView()intgetMarginBottom()intgetMarginEnd()intgetMarginEnd(int px)Deprecated.intgetMarginLeft()intgetMarginRight()intgetMarginStart()intgetMarginStart(int px)Deprecated.intgetMarginTop()intgetMaxWidth()intgetMeasuredPreferredVerticalOffset()Get cached preferred vertical offset of popup window top from anchor bottom so that selected item in the popup window is drawn precisely over the anchor.intgetMeasuredSelectedItemViewHeight()To get meaningful data the value must first be computed bymeasurePreferredVerticalOffset(int).intgetPreferredVerticalOffset(int position)Deprecated.This method pre-calculates multiple values.floatgetPreferredWidthUnit()Deprecated.intgetPromptPosition()java.lang.ObjectgetSelectedItem()longgetSelectedItemId()intgetSelectedItemPosition()android.view.ViewgetSelectedView()intgetSoftInputMode()Returns the current value insetSoftInputMode(int).intgetVerticalOffset()intgetWidth()floatgetWidthUnit()booleanhasMultilineItems()booleanhasMultiLineItems()Deprecated.booleanisDropDownAlwaysVisible()booleanisInputMethodNotNeeded()booleanisModal()Returns whether the popup window will be modal when shown.booleanisShowing()voidmeasurePreferredVerticalOffset(int position)Compute preferred vertical offset of popup window top from anchor bottom so that selected item in the popup window is drawn precisely over the anchor.booleanperformItemClick(int position)Perform an item click operation on the specified list adapter position.voidpostShow()Post aShowableListMenu.show()call to the UI thread.voidsetAdapter(android.widget.ListAdapter adapter)Sets the adapter that provides the data and the views to represent the data in this popup window.voidsetAnchorView(android.view.View anchor)Sets the popup's anchor view.voidsetAnimationStyle(int animationStyle)Set an animation style to use when the popup window is shown or dismissed.voidsetBackgroundDrawable(android.graphics.drawable.Drawable d)Sets a drawable to be the background for the popup window.voidsetBoundsView(android.view.View bounds)voidsetContentWidth(int width)Sets the width of the popup window by the size of its content.voidsetDropDownAlwaysVisible(boolean dropDownAlwaysVisible)Sets whether the drop-down should remain visible under certain conditions.voidsetDropDownGravity(int gravity)Set the gravity of the dropdown list.voidsetEpicenterBounds(android.graphics.Rect bounds)Specifies the anchor-relative bounds of the popup's transition epicenter.voidsetForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch)Forces outside touches to be ignored.voidsetHeight(int height)Sets the height of the popup window in pixels.voidsetHorizontalOffset(int offset)Set the horizontal offset of this popup from its anchor view in pixels.voidsetInputMethodMode(int mode)Control how the popup operates with an input method: one ofINPUT_METHOD_FROM_FOCUSABLE,INPUT_METHOD_NEEDED, orINPUT_METHOD_NOT_NEEDED.voidsetListSelector(android.graphics.drawable.Drawable selector)Sets a drawable to use as the list item selector.voidsetMargin(int margin)voidsetMargin(int horizontal, int vertical)voidsetMargin(int left, int top, int right, int bottom)voidsetMarginBottom(int px)voidsetMarginEnd(int px)voidsetMarginLeft(int px)voidsetMarginRelative(int start, int top, int end, int bottom)voidsetMarginRight(int px)voidsetMarginStart(int px)voidsetMarginTop(int px)voidsetMaxItemCount(int maxItemCount)voidsetMaxWidth(int maxWidth)Sets the maximum width of the popup menu in pixels.voidsetModal(boolean modal)Set whether this window should be modal when shown.voidsetOnDismissListener(android.widget.PopupWindow.OnDismissListener listener)Set a listener to receive a callback when the popup is dismissed.voidsetOnItemClickListener(android.widget.AdapterView.OnItemClickListener clickListener)Sets a listener to receive events when a list item is clicked.voidsetOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener selectedListener)Sets a listener to receive events when a list item is selected.voidsetPreferredWidthUnit(float unit)Deprecated.voidsetPromptPosition(int position)Set where the optional prompt view should appear.voidsetPromptView(android.view.View prompt)Set a view to act as a user prompt for this popup window.voidsetSelection(int position)Mark item on specified position checked, selected and positioned over anchor view.voidsetSoftInputMode(int mode)Sets the operating mode for the soft input area.voidsetVerticalOffset(int offset)Set the vertical offset of this popup from its anchor view in pixels.voidsetWidth(int width)Sets the preferred width of the popup window in pixels.voidsetWidthUnit(float widthUnit)voidsetWindowLayoutType(int layoutType)Set the layout type for this popup window.voidshow()Show the popup list.
-
-
-
Field Detail
-
POSITION_PROMPT_ABOVE
public static final int POSITION_PROMPT_ABOVE
The provided prompt view should appear above list content.
-
POSITION_PROMPT_BELOW
public static final int POSITION_PROMPT_BELOW
The provided prompt view should appear below list content.
-
WIDTH_MATCH_CONSTRAINT
public static final int WIDTH_MATCH_CONSTRAINT
Popup menu width is only limited bymaxWidth.- See Also:
- Constant Field Values
-
WIDTH_WRAP_CONTENT
public static final int WIDTH_WRAP_CONTENT
Popup menu width is * at least as wide as its content, * limited bymaxWidth.- See Also:
- Constant Field Values
-
WIDTH_WRAP_CONTENT_UNIT
public static final int WIDTH_WRAP_CONTENT_UNIT
Popup menu width is- at least as wide as its content rounded up to a multiple of
widthUnit, - at least as wide as
widthUnit * 1.5, - limited by
maxWidth.
- See Also:
- Constant Field Values
- at least as wide as its content rounded up to a multiple of
-
MAX_WIDTH_FIT_SCREEN
public static final int MAX_WIDTH_FIT_SCREEN
Popup menu width is limited by screen width.- See Also:
setMaxWidth(int), Constant Field Values
-
MAX_WIDTH_FIT_ANCHOR
public static final int MAX_WIDTH_FIT_ANCHOR
Popup menu width is limited by anchor width.- See Also:
setMaxWidth(int), Constant Field Values
-
MATCH_PARENT
public static final int MATCH_PARENT
- See Also:
- Constant Field Values
-
WRAP_CONTENT
public static final int WRAP_CONTENT
- See Also:
- Constant Field Values
-
PREFERRED
@Deprecated public static final int PREFERRED
Deprecated.- See Also:
- Constant Field Values
-
INPUT_METHOD_FROM_FOCUSABLE
public static final int INPUT_METHOD_FROM_FOCUSABLE
Mode forsetInputMethodMode(int): the requirements for the input method should be based on the focusability of the popup. That is if it is focusable than it needs to work with the input method, else it doesn't.- See Also:
- Constant Field Values
-
INPUT_METHOD_NEEDED
public static final int INPUT_METHOD_NEEDED
Mode forsetInputMethodMode(int): this popup always needs to work with an input method, regardless of whether it is focusable. This means that it will always be displayed so that the user can also operate the input method while it is shown.- See Also:
- Constant Field Values
-
INPUT_METHOD_NOT_NEEDED
public static final int INPUT_METHOD_NOT_NEEDED
Mode forsetInputMethodMode(int): this popup never needs to work with an input method, regardless of whether it is focusable. This means that it will always be displayed to use as much space on the screen as needed, regardless of whether this covers the input method.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XpListPopupWindow
public XpListPopupWindow(@NonNull android.content.Context context)
-
XpListPopupWindow
public XpListPopupWindow(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
-
XpListPopupWindow
public XpListPopupWindow(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs, @AttrRes int defStyleAttr)
-
XpListPopupWindow
public XpListPopupWindow(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes)
-
-
Method Detail
-
setMarginTop
public void setMarginTop(int px)
-
getMarginTop
public int getMarginTop()
-
setMarginBottom
public void setMarginBottom(int px)
-
getMarginBottom
public int getMarginBottom()
-
setMarginLeft
public void setMarginLeft(int px)
-
setMarginStart
public void setMarginStart(int px)
-
getMarginStart
@Deprecated public int getMarginStart(int px)
Deprecated.
-
getMarginStart
public int getMarginStart()
-
getMarginLeft
public int getMarginLeft()
-
setMarginRight
public void setMarginRight(int px)
-
setMarginEnd
public void setMarginEnd(int px)
-
getMarginEnd
@Deprecated public int getMarginEnd(int px)
Deprecated.
-
getMarginEnd
public int getMarginEnd()
-
getMarginRight
public int getMarginRight()
-
setMargin
public void setMargin(int margin)
-
setMargin
public void setMargin(int horizontal, int vertical)
-
setMargin
public void setMargin(int left, int top, int right, int bottom)
-
setMarginRelative
public void setMarginRelative(int start, int top, int end, int bottom)
-
hasMultilineItems
public boolean hasMultilineItems()
- Returns:
- Whether the list in current setup would show any multiline items.
-
hasMultiLineItems
@Deprecated public boolean hasMultiLineItems()
Deprecated.- Returns:
- Whether the list in current setup would show any multiline items.
-
setAdapter
public void setAdapter(@Nullable android.widget.ListAdapter adapter)Sets the adapter that provides the data and the views to represent the data in this popup window.- Parameters:
adapter- The adapter to use to create this window's content.
-
setPromptPosition
public void setPromptPosition(int position)
Set where the optional prompt view should appear. The default isPOSITION_PROMPT_ABOVE.- Parameters:
position- A position constant declaring where the prompt should be displayed.- See Also:
POSITION_PROMPT_ABOVE,POSITION_PROMPT_BELOW
-
getPromptPosition
public int getPromptPosition()
- Returns:
- Where the optional prompt view should appear.
- See Also:
POSITION_PROMPT_ABOVE,POSITION_PROMPT_BELOW
-
setModal
public void setModal(boolean modal)
Set whether this window should be modal when shown.If a popup window is modal, it will receive all touch and key input. If the user touches outside the popup window's content area the popup window will be dismissed.
- Parameters:
modal-trueif the popup window should be modal,falseotherwise.
-
isModal
public boolean isModal()
Returns whether the popup window will be modal when shown.- Returns:
trueif the popup window will be modal,falseotherwise.
-
setForceIgnoreOutsideTouch
public void setForceIgnoreOutsideTouch(boolean forceIgnoreOutsideTouch)
Forces outside touches to be ignored. Normally ifisDropDownAlwaysVisible()is false, we allow outside touch to dismiss the dropdown. If this is set to true, then we ignore outside touch even when the drop down is not set to always visible.
-
setDropDownAlwaysVisible
public void setDropDownAlwaysVisible(boolean dropDownAlwaysVisible)
Sets whether the drop-down should remain visible under certain conditions. The drop-down will occupy the entire screen belowgetAnchorView()regardless of the size or content of the list.getBackground()will fill any space that is not used by the list.- Parameters:
dropDownAlwaysVisible- Whether to keep the drop-down visible.
-
isDropDownAlwaysVisible
public boolean isDropDownAlwaysVisible()
- Returns:
- Whether the drop-down is visible under special conditions.
-
setSoftInputMode
public void setSoftInputMode(int mode)
Sets the operating mode for the soft input area.- Parameters:
mode- The desired mode, seeWindowManager.LayoutParams.softInputModefor the full list- See Also:
WindowManager.LayoutParams.softInputMode,getSoftInputMode()
-
getSoftInputMode
public int getSoftInputMode()
Returns the current value insetSoftInputMode(int).- See Also:
setSoftInputMode(int),WindowManager.LayoutParams.softInputMode
-
setListSelector
public void setListSelector(@Nullable android.graphics.drawable.Drawable selector)Sets a drawable to use as the list item selector.- Parameters:
selector- List selector drawable to use in the popup.
-
getBackground
@Nullable public android.graphics.drawable.Drawable getBackground()
- Returns:
- The background drawable for the popup window.
-
setBackgroundDrawable
public void setBackgroundDrawable(@Nullable android.graphics.drawable.Drawable d)Sets a drawable to be the background for the popup window.- Parameters:
d- A drawable to set as the background.
-
setAnimationStyle
public void setAnimationStyle(int animationStyle)
Set an animation style to use when the popup window is shown or dismissed.- Parameters:
animationStyle- Animation style to use.
-
getAnimationStyle
@StyleRes public int getAnimationStyle()
Returns the animation style that will be used when the popup window is shown or dismissed.- Returns:
- Animation style that will be used.
-
getAnchorView
@Nullable public android.view.View getAnchorView()
Returns the view that will be used to anchor this popup.- Returns:
- The popup's anchor view
-
setAnchorView
public void setAnchorView(@Nullable android.view.View anchor)Sets the popup's anchor view. This popup will always be positioned relative to the anchor view when shown.- Parameters:
anchor- The view to use as an anchor.
-
getBoundsView
@Nullable public android.view.View getBoundsView()
-
setBoundsView
public void setBoundsView(@Nullable android.view.View bounds)
-
getHorizontalOffset
public int getHorizontalOffset()
- Returns:
- The horizontal offset of the popup from its anchor in pixels.
-
setHorizontalOffset
public void setHorizontalOffset(int offset)
Set the horizontal offset of this popup from its anchor view in pixels.- Parameters:
offset- The horizontal offset of the popup from its anchor.
-
getVerticalOffset
public int getVerticalOffset()
- Returns:
- The vertical offset of the popup from its anchor in pixels.
-
setVerticalOffset
public void setVerticalOffset(int offset)
Set the vertical offset of this popup from its anchor view in pixels.- Parameters:
offset- The vertical offset of the popup from its anchor.
-
setEpicenterBounds
public void setEpicenterBounds(@Nullable android.graphics.Rect bounds)Specifies the anchor-relative bounds of the popup's transition epicenter.- Parameters:
bounds- anchor-relative bounds
-
setDropDownGravity
public void setDropDownGravity(int gravity)
Set the gravity of the dropdown list. This is commonly used to set gravity to START or END for alignment with the anchor.- Parameters:
gravity- Gravity value to use
-
getDropDownGravity
public int getDropDownGravity()
-
getWidth
public int getWidth()
- Returns:
- The width of the popup window in pixels.
-
getMaxWidth
public int getMaxWidth()
-
getPreferredWidthUnit
@Deprecated @Dimension public float getPreferredWidthUnit()
Deprecated.
-
getWidthUnit
@Dimension public float getWidthUnit()
- Returns:
- Min width unit size.
-
setWidth
public void setWidth(int width)
Sets the preferred width of the popup window in pixels. Can also beWIDTH_MATCH_CONSTRAINTorWIDTH_WRAP_CONTENTorWIDTH_WRAP_CONTENT_UNIT.- Parameters:
width- Preferred width of the popup window.
-
setMaxWidth
public void setMaxWidth(int maxWidth)
Sets the maximum width of the popup menu in pixels. Can also beMAX_WIDTH_FIT_SCREENorMAX_WIDTH_FIT_ANCHOR.- Parameters:
maxWidth- Maximum width of the popup window.
-
setPreferredWidthUnit
@Deprecated public void setPreferredWidthUnit(@Dimension float unit)Deprecated.- See Also:
setWidthUnit(float)
-
setWidthUnit
public void setWidthUnit(@Dimension float widthUnit)- Parameters:
widthUnit- WhengetWidth()is set toWIDTH_WRAP_CONTENT_UNITpopup width will be- at least as wide as its content rounded up to a multiple of
widthUnit, - at least as wide as
widthUnit * 1.5, - limited by
getMaxWidth().
- at least as wide as its content rounded up to a multiple of
- See Also:
WIDTH_WRAP_CONTENT_UNIT
-
setContentWidth
public void setContentWidth(int width)
Sets the width of the popup window by the size of its content. The final width may be larger to accommodate styled window dressing.- Parameters:
width- Desired width of content in pixels.
-
getHeight
public int getHeight()
- Returns:
- The height of the popup window in pixels.
-
setHeight
public void setHeight(int height)
Sets the height of the popup window in pixels. Can also beMATCH_PARENT.- Parameters:
height- Height of the popup window.- Throws:
java.lang.IllegalArgumentException- if height is set to negative value
-
setMaxItemCount
public void setMaxItemCount(int maxItemCount)
- Parameters:
maxItemCount- Popup menu will adjust its height to display at most this many items.
-
setWindowLayoutType
public void setWindowLayoutType(int layoutType)
Set the layout type for this popup window. SeeWindowManager.LayoutParams.typefor possible values.- Parameters:
layoutType- Layout type for this window.- See Also:
WindowManager.LayoutParams.type
-
setOnItemClickListener
public void setOnItemClickListener(@Nullable android.widget.AdapterView.OnItemClickListener clickListener)Sets a listener to receive events when a list item is clicked.- Parameters:
clickListener- Listener to register- See Also:
AdapterView.setOnItemClickListener(AdapterView.OnItemClickListener)
-
setOnItemSelectedListener
public void setOnItemSelectedListener(@Nullable android.widget.AdapterView.OnItemSelectedListener selectedListener)Sets a listener to receive events when a list item is selected.- Parameters:
selectedListener- Listener to register.- See Also:
AdapterView.setOnItemSelectedListener(AdapterView.OnItemSelectedListener)
-
setPromptView
public void setPromptView(@Nullable android.view.View prompt)Set a view to act as a user prompt for this popup window. Where the prompt view will appear is controlled bysetPromptPosition(int).- Parameters:
prompt- View to use as an informational prompt.
-
postShow
public void postShow()
Post aShowableListMenu.show()call to the UI thread.
-
show
@MainThread public void show()
Show the popup list. If the list is already showing, this method will do nothing.- Specified by:
showin interfaceandroidx.appcompat.view.menu.ShowableListMenu
-
dismiss
public void dismiss()
Dismiss the popup window.- Specified by:
dismissin interfaceandroidx.appcompat.view.menu.ShowableListMenu
-
setOnDismissListener
public void setOnDismissListener(@Nullable android.widget.PopupWindow.OnDismissListener listener)Set a listener to receive a callback when the popup is dismissed.- Parameters:
listener- Listener that will be notified when the popup is dismissed.
-
setInputMethodMode
public void setInputMethodMode(int mode)
Control how the popup operates with an input method: one ofINPUT_METHOD_FROM_FOCUSABLE,INPUT_METHOD_NEEDED, orINPUT_METHOD_NOT_NEEDED.If the popup is showing, calling this method will take effect only the next time the popup is shown or through a manual call to the
ShowableListMenu.show()method.- See Also:
getInputMethodMode(),ShowableListMenu.show()
-
getInputMethodMode
public int getInputMethodMode()
Return the current value insetInputMethodMode(int).- See Also:
setInputMethodMode(int)
-
setSelection
public void setSelection(int position)
Mark item on specified position checked, selected and positioned over anchor view.- Parameters:
position- Selected item index.
-
getMeasuredPreferredVerticalOffset
public int getMeasuredPreferredVerticalOffset()
Get cached preferred vertical offset of popup window top from anchor bottom so that selected item in the popup window is drawn precisely over the anchor. To get meaningful data the value must first be computed bymeasurePreferredVerticalOffset(int).- Returns:
- Cached measured vertical offset for popup window.
- See Also:
measurePreferredVerticalOffset(int),getMeasuredSelectedItemViewHeight()
-
getMeasuredSelectedItemViewHeight
public int getMeasuredSelectedItemViewHeight()
To get meaningful data the value must first be computed bymeasurePreferredVerticalOffset(int).- Returns:
- Measured height of selected item view.
- See Also:
measurePreferredVerticalOffset(int),getMeasuredPreferredVerticalOffset()
-
measurePreferredVerticalOffset
public void measurePreferredVerticalOffset(int position)
Compute preferred vertical offset of popup window top from anchor bottom so that selected item in the popup window is drawn precisely over the anchor. It also calculates selected item view height.- Parameters:
position- Which item is supposed to be selected, and preferably aligned over anchor.- See Also:
getMeasuredPreferredVerticalOffset(),getMeasuredSelectedItemViewHeight()
-
getPreferredVerticalOffset
@Deprecated public int getPreferredVerticalOffset(int position)
Deprecated.This method pre-calculates multiple values. Use specialized accessor methods.Measures popup offset and selected item scroll offset for selected item to be positioned exactly over anchor.- Parameters:
position- Which item is supposed to be selected, and preferably aligned over anchor.- Returns:
- Measured vertical offset for popup window.
- See Also:
measurePreferredVerticalOffset(int),getMeasuredPreferredVerticalOffset(),getMeasuredSelectedItemViewHeight()
-
clearListSelection
public void clearListSelection()
Clear any current list selection. Only valid whenShowableListMenu.isShowing()==true.
-
isShowing
public boolean isShowing()
- Specified by:
isShowingin interfaceandroidx.appcompat.view.menu.ShowableListMenu- Returns:
trueif the popup is currently showing,falseotherwise.
-
isInputMethodNotNeeded
public boolean isInputMethodNotNeeded()
- Returns:
trueif this popup is configured to assume the user does not need to interact with the IME while it is showing,falseotherwise.
-
performItemClick
public boolean performItemClick(int position)
Perform an item click operation on the specified list adapter position.- Parameters:
position- Adapter position for performing the click- Returns:
- true if the click action could be performed, false if not. (e.g. if the popup was not showing, this method would return false.)
-
getSelectedItem
@Nullable public java.lang.Object getSelectedItem()
- Returns:
- The currently selected item or null if the popup is not showing.
-
getSelectedItemPosition
public int getSelectedItemPosition()
- Returns:
- The position of the currently selected item or
AdapterView.INVALID_POSITIONifShowableListMenu.isShowing()==false. - See Also:
AdapterView.getSelectedItemPosition()
-
getSelectedItemId
public long getSelectedItemId()
- Returns:
- The ID of the currently selected item or
AdapterView.INVALID_ROW_IDifShowableListMenu.isShowing()==false. - See Also:
AdapterView.getSelectedItemId()
-
getSelectedView
@Nullable public android.view.View getSelectedView()
- Returns:
- The View for the currently selected item or null if
ShowableListMenu.isShowing()==false. - See Also:
AbsListView.getSelectedView()
-
getListView
@Nullable public android.widget.ListView getListView()
- Specified by:
getListViewin interfaceandroidx.appcompat.view.menu.ShowableListMenu- Returns:
- The
ListViewdisplayed within the popup window. Only valid whenShowableListMenu.isShowing()==true.
-
createDragToOpenListener
@Deprecated @NonNull public android.view.View.OnTouchListener createDragToOpenListener(@NonNull android.view.View src)Deprecated.This feature is currently not supported.Returns anView.OnTouchListenerthat can be added to the source view to implement drag-to-open behavior. Generally, the source view should be the same view that was passed tosetAnchorView(android.view.View).When the listener is set on a view, touching that view and dragging outside of its bounds will open the popup window. Lifting will select the currently touched list item.
Example usage:
ListPopupWindow myPopup = new ListPopupWindow(context); myPopup.setAnchor(myAnchor); OnTouchListener dragListener = myPopup.createDragToOpenListener(myAnchor); myAnchor.setOnTouchListener(dragListener);
- Parameters:
src- the view on which the resulting listener will be set- Returns:
- a touch listener that controls drag-to-open behavior
-
-