added in version 25.1.0
belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1

ListPopupWindow

public class ListPopupWindow
extends Object

java.lang.Object
   ↳ android.support.v7.widget.ListPopupWindow


Static library support version of the framework's ListPopupWindow. Used to write apps that run on platforms prior to Android L. When running on Android L or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview.

See also:

Summary

Constants

int INPUT_METHOD_FROM_FOCUSABLE

Mode for setInputMethodMode(int): the requirements for the input method should be based on the focusability of the popup.

int INPUT_METHOD_NEEDED

Mode for setInputMethodMode(int): this popup always needs to work with an input method, regardless of whether it is focusable.

int INPUT_METHOD_NOT_NEEDED

Mode for setInputMethodMode(int): this popup never needs to work with an input method, regardless of whether it is focusable.

int MATCH_PARENT

Alias for MATCH_PARENT.

int POSITION_PROMPT_ABOVE

The provided prompt view should appear above list content.

int POSITION_PROMPT_BELOW

The provided prompt view should appear below list content.

int WRAP_CONTENT

Alias for WRAP_CONTENT.

Public constructors

ListPopupWindow(Context context)

Create a new, empty popup window capable of displaying items from a ListAdapter.

ListPopupWindow(Context context, AttributeSet attrs)

Create a new, empty popup window capable of displaying items from a ListAdapter.

ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr)

Create a new, empty popup window capable of displaying items from a ListAdapter.

ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Create a new, empty popup window capable of displaying items from a ListAdapter.

Public methods

void clearListSelection()

Clear any current list selection.

View.OnTouchListener createDragToOpenListener(View src)

Returns an View.OnTouchListener that can be added to the source view to implement drag-to-open behavior.

void dismiss()

Dismiss the popup window.

View getAnchorView()

Returns the view that will be used to anchor this popup.

int getAnimationStyle()

Returns the animation style that will be used when the popup window is shown or dismissed.

Drawable getBackground()
int getHeight()
int getHorizontalOffset()
int getInputMethodMode()

Return the current value in setInputMethodMode(int).

ListView getListView()
int getPromptPosition()
Object getSelectedItem()
long getSelectedItemId()
int getSelectedItemPosition()
View getSelectedView()
int getSoftInputMode()

Returns the current value in setSoftInputMode(int).

int getVerticalOffset()
int getWidth()
boolean isInputMethodNotNeeded()
boolean isModal()

Returns whether the popup window will be modal when shown.

boolean isShowing()
boolean onKeyDown(int keyCode, KeyEvent event)

Filter key down events.

boolean onKeyPreIme(int keyCode, KeyEvent event)

Filter pre-IME key events.

boolean onKeyUp(int keyCode, KeyEvent event)

Filter key up events.

boolean performItemClick(int position)

Perform an item click operation on the specified list adapter position.

void postShow()

Post a show() call to the UI thread.

void setAdapter(ListAdapter adapter)

Sets the adapter that provides the data and the views to represent the data in this popup window.

void setAnchorView(View anchor)

Sets the popup's anchor view.

void setAnimationStyle(int animationStyle)

Set an animation style to use when the popup window is shown or dismissed.

void setBackgroundDrawable(Drawable d)

Sets a drawable to be the background for the popup window.

void setContentWidth(int width)

Sets the width of the popup window by the size of its content.

void setDropDownGravity(int gravity)

Set the gravity of the dropdown list.

void setHeight(int height)

Sets the height of the popup window in pixels.

void setHorizontalOffset(int offset)

Set the horizontal offset of this popup from its anchor view in pixels.

void setInputMethodMode(int mode)

Control how the popup operates with an input method: one of INPUT_METHOD_FROM_FOCUSABLE, INPUT_METHOD_NEEDED, or INPUT_METHOD_NOT_NEEDED.

void setListSelector(Drawable selector)

Sets a drawable to use as the list item selector.

void setModal(boolean modal)

Set whether this window should be modal when shown.

void setOnDismissListener(PopupWindow.OnDismissListener listener)

Set a listener to receive a callback when the popup is dismissed.

void setOnItemClickListener(AdapterView.OnItemClickListener clickListener)

Sets a listener to receive events when a list item is clicked.

void setOnItemSelectedListener(AdapterView.OnItemSelectedListener selectedListener)

Sets a listener to receive events when a list item is selected.

void setPromptPosition(int position)

Set where the optional prompt view should appear.

void setPromptView(View prompt)

Set a view to act as a user prompt for this popup window.

void setSelection(int position)

Set the selected position of the list.

void setSoftInputMode(int mode)

Sets the operating mode for the soft input area.

void setVerticalOffset(int offset)

Set the vertical offset of this popup from its anchor view in pixels.

void setWidth(int width)

Sets the width of the popup window in pixels.

void setWindowLayoutType(int layoutType)

Set the layout type for this popup window.

void show()

Show the popup list.

Inherited methods

From class java.lang.Object

Constants

INPUT_METHOD_FROM_FOCUSABLE

added in version 25.1.0
int INPUT_METHOD_FROM_FOCUSABLE

Mode for setInputMethodMode(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.

Constant Value: 0 (0x00000000)

INPUT_METHOD_NEEDED

added in version 25.1.0
int INPUT_METHOD_NEEDED

Mode for setInputMethodMode(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.

Constant Value: 1 (0x00000001)

INPUT_METHOD_NOT_NEEDED

added in version 25.1.0
int INPUT_METHOD_NOT_NEEDED

Mode for setInputMethodMode(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.

Constant Value: 2 (0x00000002)

MATCH_PARENT

added in version 25.1.0
int MATCH_PARENT

Alias for MATCH_PARENT. If used to specify a popup width, the popup will match the width of the anchor view. If used to specify a popup height, the popup will fill available space.

Constant Value: -1 (0xffffffff)

POSITION_PROMPT_ABOVE

added in version 25.1.0
int POSITION_PROMPT_ABOVE

The provided prompt view should appear above list content.

Constant Value: 0 (0x00000000)

POSITION_PROMPT_BELOW

added in version 25.1.0
int POSITION_PROMPT_BELOW

The provided prompt view should appear below list content.

Constant Value: 1 (0x00000001)

WRAP_CONTENT

added in version 25.1.0
int WRAP_CONTENT

Alias for WRAP_CONTENT. If used to specify a popup width, the popup will use the width of its content.

Constant Value: -2 (0xfffffffe)

Public constructors

ListPopupWindow

added in version 25.1.0
ListPopupWindow (Context context)

Create a new, empty popup window capable of displaying items from a ListAdapter. Backgrounds should be set using setBackgroundDrawable(Drawable).

Parameters