Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [XML Attrs](https://developer.android.com/reference/android/widget/ListPopupWindow#lattrs) \| [Constants](https://developer.android.com/reference/android/widget/ListPopupWindow#constants) \| [Ctors](https://developer.android.com/reference/android/widget/ListPopupWindow#pubctors) \| [Methods](https://developer.android.com/reference/android/widget/ListPopupWindow#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/widget/ListPopupWindow#inhmethods)

# ListPopupWindow

*** ** * ** ***

` public class ListPopupWindow `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.widget.ListPopupWindow |

<br />

*** ** * ** ***

A ListPopupWindow anchors itself to a host view and displays a list of choices.

ListPopupWindow contains a number of tricky behaviors surrounding positioning, scrolling parents to fit the dropdown, interacting sanely with the IME if present, and others.
**See also:**

- `https://developer.android.com/reference/android/widget/AutoCompleteTextView`
- `https://developer.android.com/reference/android/widget/Spinner`

## Summary

| ### XML attributes ||
|---|---|
| [`android:dropDownHorizontalOffset`](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownHorizontalOffset) | Amount of pixels by which the drop down should be offset horizontally. |
| [`android:dropDownVerticalOffset`](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownVerticalOffset) | Amount of pixels by which the drop down should be offset vertically. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE` Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`: the requirements for the input method should be based on the focusability of the popup. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_NEEDED` Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`: this popup always needs to work with an input method, regardless of whether it is focusable. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_NOT_NEEDED` Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`: this popup never needs to work with an input method, regardless of whether it is focusable. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#MATCH_PARENT` Alias for `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#MATCH_PARENT`. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_ABOVE` The provided prompt view should appear above list content. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_BELOW` The provided prompt view should appear below list content. |
| `int` | `https://developer.android.com/reference/android/widget/ListPopupWindow#WRAP_CONTENT` Alias for `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#WRAP_CONTENT`. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/widget/ListPopupWindow#ListPopupWindow(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Create a new, empty popup window capable of displaying items from a ListAdapter. |
| ` https://developer.android.com/reference/android/widget/ListPopupWindow#ListPopupWindow(android.content.Context,%20android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Create a new, empty popup window capable of displaying items from a ListAdapter. |
| ` https://developer.android.com/reference/android/widget/ListPopupWindow#ListPopupWindow(android.content.Context,%20android.util.AttributeSet,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/util/AttributeSet attrs, int defStyleAttr) ` Create a new, empty popup window capable of displaying items from a ListAdapter. |
| ` https://developer.android.com/reference/android/widget/ListPopupWindow#ListPopupWindow(android.content.Context,%20android.util.AttributeSet,%20int,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/util/AttributeSet attrs, int defStyleAttr, int defStyleRes) ` Create a new, empty popup window capable of displaying items from a ListAdapter. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#clearListSelection()() ` Clear any current list selection. |
| ` https://developer.android.com/reference/android/view/View.OnTouchListener` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#createDragToOpenListener(android.view.View)(https://developer.android.com/reference/android/view/View src) ` Returns an `https://developer.android.com/reference/android/view/View.OnTouchListener` that can be added to the source view to implement drag-to-open behavior. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#dismiss()() ` Dismiss the popup window. |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getAnchorView()() ` Returns the view that will be used to anchor this popup. |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getAnimationStyle()() ` Returns the animation style that will be used when the popup window is shown or dismissed. |
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getBackground()() ` |
| ` https://developer.android.com/reference/android/graphics/Rect` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getEpicenterBounds()() ` Returns bounds which are used as a popup's epicenter of the enter and exit transitions. |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getHeight()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getHorizontalOffset()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getInputMethodMode()() ` Return the current value in `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`. |
| ` https://developer.android.com/reference/android/widget/ListView` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getListView()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getPromptPosition()() ` |
| ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getSelectedItem()() ` |
| ` long` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getSelectedItemId()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getSelectedItemPosition()() ` |
| ` https://developer.android.com/reference/android/view/View` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getSelectedView()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getSoftInputMode()() ` Returns the current value in `https://developer.android.com/reference/android/widget/ListPopupWindow#setSoftInputMode(int)`. |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getVerticalOffset()() ` |
| ` int` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#getWidth()() ` |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#isInputMethodNotNeeded()() ` |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#isModal()() ` Returns whether the popup window will be modal when shown. |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()() ` |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#onKeyDown(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Filter key down events. |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#onKeyPreIme(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Filter pre-IME key events. |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#onKeyUp(int,%20android.view.KeyEvent)(int keyCode, https://developer.android.com/reference/android/view/KeyEvent event) ` Filter key up events. |
| ` boolean` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#performItemClick(int)(int position) ` Perform an item click operation on the specified list adapter position. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#postShow()() ` Post a `https://developer.android.com/reference/android/widget/ListPopupWindow#show()` call to the UI thread. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setAdapter(android.widget.ListAdapter)(https://developer.android.com/reference/android/widget/ListAdapter adapter) ` Sets the adapter that provides the data and the views to represent the data in this popup window. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setAnchorView(android.view.View)(https://developer.android.com/reference/android/view/View anchor) ` Sets the popup's anchor view. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setAnimationStyle(int)(int animationStyle) ` Set an animation style to use when the popup window is shown or dismissed. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setBackgroundDrawable(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable d) ` Sets a drawable to be the background for the popup window. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setContentWidth(int)(int width) ` Sets the width of the popup window by the size of its content. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setDropDownGravity(int)(int gravity) ` Set the gravity of the dropdown list. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setEpicenterBounds(android.graphics.Rect)(https://developer.android.com/reference/android/graphics/Rect bounds) ` Specifies the anchor-relative bounds of the popup's transition epicenter. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setHeight(int)(int height) ` Sets the height of the popup window in pixels. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setHorizontalOffset(int)(int offset) ` Set the horizontal offset of this popup from its anchor view in pixels. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)(int mode) ` Control how the popup operates with an input method: one of `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE`, `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_NEEDED`, or `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_NOT_NEEDED`. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setListSelector(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable selector) ` Sets a drawable to use as the list item selector. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setModal(boolean)(boolean modal) ` Set whether this window should be modal when shown. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setOnDismissListener(android.widget.PopupWindow.OnDismissListener)(https://developer.android.com/reference/android/widget/PopupWindow.OnDismissListener listener) ` Set a listener to receive a callback when the popup is dismissed. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setOnItemClickListener(android.widget.AdapterView.OnItemClickListener)(https://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener clickListener) ` Sets a listener to receive events when a list item is clicked. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)(https://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener selectedListener) ` Sets a listener to receive events when a list item is selected. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptPosition(int)(int position) ` Set where the optional prompt view should appear. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptView(android.view.View)(https://developer.android.com/reference/android/view/View prompt) ` Set a view to act as a user prompt for this popup window. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setSelection(int)(int position) ` Set the selected position of the list. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setSoftInputMode(int)(int mode) ` Sets the operating mode for the soft input area. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setVerticalOffset(int)(int offset) ` Set the vertical offset of this popup from its anchor view in pixels. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setWidth(int)(int width) ` Sets the width of the popup window in pixels. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#setWindowLayoutType(int)(int layoutType) ` Set the layout type for this popup window. |
| ` void` | ` https://developer.android.com/reference/android/widget/ListPopupWindow#show()() ` Show the popup list. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## XML attributes

### android:dropDownHorizontalOffset

Amount of pixels by which the drop down should be offset horizontally.

May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

<br />

**Related methods:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setHorizontalOffset(int)`

### android:dropDownVerticalOffset

Amount of pixels by which the drop down should be offset vertically.

May be a dimension value, which is a floating point number appended with a unit such as "`14.5sp`". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

<br />

**Related methods:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setVerticalOffset(int)`

## Constants

### INPUT_METHOD_FROM_FOCUSABLE

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int INPUT_METHOD_FROM_FOCUSABLE
```

Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#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.

<br />

Constant Value: 0 (0x00000000)

### INPUT_METHOD_NEEDED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int INPUT_METHOD_NEEDED
```

Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#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.

<br />

Constant Value: 1 (0x00000001)

### INPUT_METHOD_NOT_NEEDED

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int INPUT_METHOD_NOT_NEEDED
```

Mode for `https://developer.android.com/reference/android/widget/ListPopupWindow#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.

<br />

Constant Value: 2 (0x00000002)

### MATCH_PARENT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int MATCH_PARENT
```

Alias for `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#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.

<br />

Constant Value: -1 (0xffffffff)

### POSITION_PROMPT_ABOVE

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int POSITION_PROMPT_ABOVE
```

The provided prompt view should appear above list content.

<br />

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptPosition(int)`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#getPromptPosition()`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptView(android.view.View)`

Constant Value: 0 (0x00000000)

### POSITION_PROMPT_BELOW

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int POSITION_PROMPT_BELOW
```

The provided prompt view should appear below list content.

<br />

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptPosition(int)`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#getPromptPosition()`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptView(android.view.View)`

Constant Value: 1 (0x00000001)

### WRAP_CONTENT

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int WRAP_CONTENT
```

Alias for `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams#WRAP_CONTENT`. If used to specify a popup width, the popup will use the width of its content.

<br />

Constant Value: -2 (0xfffffffe)

## Public constructors

### ListPopupWindow

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListPopupWindow (Context context)
```

Create a new, empty popup window capable of displaying items from a ListAdapter. Backgrounds should be set using `https://developer.android.com/reference/android/widget/ListPopupWindow#setBackgroundDrawable(android.graphics.drawable.Drawable)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Context used for contained views. This value cannot be `null`. <br /> |

### ListPopupWindow

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListPopupWindow (Context context, 
                AttributeSet attrs)
```

Create a new, empty popup window capable of displaying items from a ListAdapter. Backgrounds should be set using `https://developer.android.com/reference/android/widget/ListPopupWindow#setBackgroundDrawable(android.graphics.drawable.Drawable)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Context used for contained views. This value cannot be `null`. <br /> |
| `attrs` | `AttributeSet`: Attributes from inflating parent views used to style the popup. This value may be `null`. <br /> |

### ListPopupWindow

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListPopupWindow (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)
```

Create a new, empty popup window capable of displaying items from a ListAdapter. Backgrounds should be set using `https://developer.android.com/reference/android/widget/ListPopupWindow#setBackgroundDrawable(android.graphics.drawable.Drawable)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Context used for contained views. This value cannot be `null`. <br /> |
| `attrs` | `AttributeSet`: Attributes from inflating parent views used to style the popup. This value may be `null`. <br /> |
| `defStyleAttr` | `int`: Default style attribute to use for popup content. <br /> |

### ListPopupWindow

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Create a new, empty popup window capable of displaying items from a ListAdapter. Backgrounds should be set using `https://developer.android.com/reference/android/widget/ListPopupWindow#setBackgroundDrawable(android.graphics.drawable.Drawable)`.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Context used for contained views. This value cannot be `null`. <br /> |
| `attrs` | `AttributeSet`: Attributes from inflating parent views used to style the popup. This value may be `null`. <br /> |
| `defStyleAttr` | `int`: Style attribute to read for default styling of popup content. <br /> |
| `defStyleRes` | `int`: Style resource ID to use for default styling of popup content. <br /> |

## Public methods

### clearListSelection

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void clearListSelection ()
```

Clear any current list selection. Only valid when `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `true`.

<br />

### createDragToOpenListener

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View.OnTouchListener createDragToOpenListener (View src)
```

Returns an `https://developer.android.com/reference/android/view/View.OnTouchListener` that 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 to `https://developer.android.com/reference/android/widget/ListPopupWindow#setAnchorView(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);
```

<br />

<br />

| Parameters ||
|---|---|
| `src` | `View`: the view on which the resulting listener will be set <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View.OnTouchListener` | a touch listener that controls drag-to-open behavior <br /> |

### dismiss

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void dismiss ()
```

Dismiss the popup window.

<br />

### getAnchorView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View getAnchorView ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The popup's anchor view. This value may be `null`. <br /> |

### getAnimationStyle

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getAnimationStyle ()
```

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

<br />

| Returns ||
|---|---|
| `int` | Animation style that will be used. <br /> |

### getBackground

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Drawable getBackground ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | The background drawable for the popup window. This value may be `null`. <br /> |

### getEpicenterBounds

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Rect getEpicenterBounds ()
```

Returns bounds which are used as a popup's epicenter of the enter and exit transitions.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/Rect` | bounds relative to anchor view, or `null` if not set <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setEpicenterBounds(android.graphics.Rect)`

### getHeight

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getHeight ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The height of the popup window in pixels. <br /> |

### getHorizontalOffset

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getHorizontalOffset ()
```

<br />

<br />

**Related XML Attributes:**

- [android:dropDownHorizontalOffset](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownHorizontalOffset)

| Returns ||
|---|---|
| `int` | The horizontal offset of the popup from its anchor in pixels. <br /> |

### getInputMethodMode

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getInputMethodMode ()
```

Return the current value in `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setInputMethodMode(int)`

### getListView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ListView getListView ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/widget/ListView` | The `https://developer.android.com/reference/android/widget/ListView` displayed within the popup window. Only valid when `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `true`. This value may be `null`. <br /> |

### getPromptPosition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getPromptPosition ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | Where the optional prompt view should appear. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_ABOVE`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_BELOW`

### getSelectedItem

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Object getSelectedItem ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Object` | The currently selected item or null if the popup is not showing. <br /> |

### getSelectedItemId

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getSelectedItemId ()
```

<br />

<br />

| Returns ||
|---|---|
| `long` | The ID of the currently selected item or `https://developer.android.com/reference/android/widget/AdapterView#INVALID_ROW_ID` if `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/AdapterView#getSelectedItemId()`

### getSelectedItemPosition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSelectedItemPosition ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The position of the currently selected item or `https://developer.android.com/reference/android/widget/AdapterView#INVALID_POSITION` if `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/AdapterView#getSelectedItemPosition()`

### getSelectedView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public View getSelectedView ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/View` | The View for the currently selected item or null if `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `false`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/AbsListView#getSelectedView()`

### getSoftInputMode

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSoftInputMode ()
```

Returns the current value in `https://developer.android.com/reference/android/widget/ListPopupWindow#setSoftInputMode(int)`.

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setSoftInputMode(int)`
- `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#softInputMode`

### getVerticalOffset

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getVerticalOffset ()
```

<br />

<br />

**Related XML Attributes:**

- [android:dropDownVerticalOffset](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownVerticalOffset)

| Returns ||
|---|---|
| `int` | The vertical offset of the popup from its anchor in pixels. <br /> |

### getWidth

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getWidth ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The width of the popup window in pixels. <br /> |

### isInputMethodNotNeeded

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isInputMethodNotNeeded ()
```

<br />

<br />

| Returns ||
|---|---|
| `boolean` | `true` if this popup is configured to assume the user does not need to interact with the IME while it is showing, `false` otherwise. <br /> |

### isModal

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isModal ()
```

Returns whether the popup window will be modal when shown.

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the popup window will be modal, `false` otherwise. <br /> |

### isShowing

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isShowing ()
```

<br />

<br />

| Returns ||
|---|---|
| `boolean` | `true` if the popup is currently showing, `false` otherwise. <br /> |

### onKeyDown

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyDown (int keyCode, 
                KeyEvent event)
```

Filter key down events. By forwarding key down events to this function, views using non-modal ListPopupWindow can have it handle key selection of items.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: keyCode param passed to the host view's onKeyDown <br /> |
| `event` | `KeyEvent`: event param passed to the host view's onKeyDown. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the event was handled, false if it was ignored. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setModal(boolean)`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#onKeyUp(int,%20android.view.KeyEvent)`

### onKeyPreIme

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyPreIme (int keyCode, 
                KeyEvent event)
```

Filter pre-IME key events. By forwarding `https://developer.android.com/reference/android/view/View#onKeyPreIme(int,%20android.view.KeyEvent)` events to this function, views using ListPopupWindow can have it dismiss the popup when the back key is pressed.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: keyCode param passed to the host view's onKeyPreIme <br /> |
| `event` | `KeyEvent`: event param passed to the host view's onKeyPreIme. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the event was handled, false if it was ignored. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setModal(boolean)`

### onKeyUp

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean onKeyUp (int keyCode, 
                KeyEvent event)
```

Filter key up events. By forwarding key up events to this function, views using non-modal ListPopupWindow can have it handle key selection of items.

<br />

| Parameters ||
|---|---|
| `keyCode` | `int`: keyCode param passed to the host view's onKeyUp <br /> |
| `event` | `KeyEvent`: event param passed to the host view's onKeyUp. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the event was handled, false if it was ignored. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#setModal(boolean)`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#onKeyDown(int,%20android.view.KeyEvent)`

### performItemClick

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean performItemClick (int position)
```

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

<br />

| Parameters ||
|---|---|
| `position` | `int`: Adapter position for performing the click <br /> |

| Returns ||
|---|---|
| `boolean` | true if the click action could be performed, false if not. (e.g. if the popup was not showing, this method would return false.) <br /> |

### postShow

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void postShow ()
```

Post a `https://developer.android.com/reference/android/widget/ListPopupWindow#show()` call to the UI thread.

<br />

### setAdapter

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAdapter (ListAdapter adapter)
```

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

<br />

| Parameters ||
|---|---|
| `adapter` | `ListAdapter`: The adapter to use to create this window's content. This value may be `null`. <br /> |

### setAnchorView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAnchorView (View anchor)
```

Sets the popup's anchor view. This popup will always be positioned relative to the anchor view when shown.

<br />

| Parameters ||
|---|---|
| `anchor` | `View`: The view to use as an anchor. This value may be `null`. <br /> |

### setAnimationStyle

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAnimationStyle (int animationStyle)
```

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

<br />

| Parameters ||
|---|---|
| `animationStyle` | `int`: Animation style to use. <br /> |

### setBackgroundDrawable

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setBackgroundDrawable (Drawable d)
```

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

<br />

| Parameters ||
|---|---|
| `d` | `Drawable`: A drawable to set as the background. This value may be `null`. <br /> |

### setContentWidth

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `width` | `int`: Desired width of content in pixels. <br /> |

### setDropDownGravity

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `gravity` | `int`: Gravity value to use <br /> |

### setEpicenterBounds

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setEpicenterBounds (Rect bounds)
```

Specifies the anchor-relative bounds of the popup's transition epicenter.

<br />

| Parameters ||
|---|---|
| `bounds` | `Rect`: anchor-relative bounds, or `null` to use default epicenter <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#getEpicenterBounds()`

### setHeight

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setHeight (int height)
```

Sets the height of the popup window in pixels. Can also be `https://developer.android.com/reference/android/widget/ListPopupWindow#MATCH_PARENT`.

<br />

| Parameters ||
|---|---|
| `height` | `int`: Height of the popup window must be a positive value, `https://developer.android.com/reference/android/widget/ListPopupWindow#MATCH_PARENT`, or `https://developer.android.com/reference/android/widget/ListPopupWindow#WRAP_CONTENT`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if height is set to negative value |

### setHorizontalOffset

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setHorizontalOffset (int offset)
```

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

<br />

**Related XML Attributes:**

- [android:dropDownHorizontalOffset](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownHorizontalOffset)

| Parameters ||
|---|---|
| `offset` | `int`: The horizontal offset of the popup from its anchor. <br /> |

### setInputMethodMode

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setInputMethodMode (int mode)
```

Control how the popup operates with an input method: one of `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_FROM_FOCUSABLE`, `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_METHOD_NEEDED`, or `https://developer.android.com/reference/android/widget/ListPopupWindow#INPUT_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 `https://developer.android.com/reference/android/widget/ListPopupWindow#show()` method.

<br />

<br />

| Parameters ||
|---|---|
| `mode` | `int` <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#getInputMethodMode()`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#show()`

### setListSelector

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setListSelector (Drawable selector)
```

Sets a drawable to use as the list item selector.

<br />

| Parameters ||
|---|---|
| `selector` | `Drawable`: List selector drawable to use in the popup. <br /> |

### setModal

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `modal` | `boolean`: `true` if the popup window should be modal, `false` otherwise. <br /> |

### setOnDismissListener

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOnDismissListener (PopupWindow.OnDismissListener listener)
```

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

<br />

| Parameters ||
|---|---|
| `listener` | `PopupWindow.OnDismissListener`: Listener that will be notified when the popup is dismissed. This value may be `null`. <br /> |

### setOnItemClickListener

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOnItemClickListener (AdapterView.OnItemClickListener clickListener)
```

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

<br />

| Parameters ||
|---|---|
| `clickListener` | `AdapterView.OnItemClickListener`: Listener to register. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/AdapterView#setOnItemClickListener(android.widget.AdapterView.OnItemClickListener)`

### setOnItemSelectedListener

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOnItemSelectedListener (AdapterView.OnItemSelectedListener selectedListener)
```

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

<br />

| Parameters ||
|---|---|
| `selectedListener` | `AdapterView.OnItemSelectedListener`: Listener to register. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/AdapterView#setOnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener)`

### setPromptPosition

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPromptPosition (int position)
```

Set where the optional prompt view should appear. The default is `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_ABOVE`.

<br />

| Parameters ||
|---|---|
| `position` | `int`: A position constant declaring where the prompt should be displayed. <br /> |

**See also:**

- `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_ABOVE`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#POSITION_PROMPT_BELOW`

### setPromptView

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPromptView (View prompt)
```

Set a view to act as a user prompt for this popup window. Where the prompt view will appear is controlled by `https://developer.android.com/reference/android/widget/ListPopupWindow#setPromptPosition(int)`.

<br />

| Parameters ||
|---|---|
| `prompt` | `View`: View to use as an informational prompt. This value may be `null`. <br /> |

### setSelection

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSelection (int position)
```

Set the selected position of the list. Only valid when `https://developer.android.com/reference/android/widget/ListPopupWindow#isShowing()` == `true`.

<br />

| Parameters ||
|---|---|
| `position` | `int`: List position to set as selected. <br /> |

### setSoftInputMode

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSoftInputMode (int mode)
```

Sets the operating mode for the soft input area.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: The desired mode, see `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#softInputMode` for the full list <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#softInputMode`
- `https://developer.android.com/reference/android/widget/ListPopupWindow#getSoftInputMode()`

### setVerticalOffset

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setVerticalOffset (int offset)
```

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

<br />

**Related XML Attributes:**

- [android:dropDownVerticalOffset](https://developer.android.com/reference/android/widget/ListPopupWindow#attr_android:dropDownVerticalOffset)

| Parameters ||
|---|---|
| `offset` | `int`: The vertical offset of the popup from its anchor. <br /> |

### setWidth

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setWidth (int width)
```

Sets the width of the popup window in pixels. Can also be `https://developer.android.com/reference/android/widget/ListPopupWindow#MATCH_PARENT` or `https://developer.android.com/reference/android/widget/ListPopupWindow#WRAP_CONTENT`.

<br />

| Parameters ||
|---|---|
| `width` | `int`: Width of the popup window. <br /> |

### setWindowLayoutType

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setWindowLayoutType (int layoutType)
```

Set the layout type for this popup window.

See `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#type` for possible values.

<br />

| Parameters ||
|---|---|
| `layoutType` | `int`: Layout type for this window. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/WindowManager.LayoutParams#type`

### show

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void show ()
```

Show the popup list. If the list is already showing, this method will recalculate the popup's size and position.

<br />