# ListPopupWindowCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/widget/ListPopupWindowCompat.java+class:androidx.core.widget.ListPopupWindowCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public final class ListPopupWindowCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/widget/ListPopupWindow.html`.

## Summary

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/android/view/View.OnTouchListener.html` | `[createDragToOpenListener](https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(java.lang.Object,android.view.View))(https://developer.android.com/reference/java/lang/Object.html listPopupWindow, https://developer.android.com/reference/android/view/View.html src)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(android.widget.ListPopupWindow,android.view.View)` that takes in `https://developer.android.com/reference/android/widget/ListPopupWindow.html` instead of `https://developer.android.com/reference/java/lang/Object.html`. <br /> |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.OnTouchListener.html` | `@https://developer.android.com/reference/androidx/annotation/ReplaceWith(expression = "listPopupWindow.createDragToOpenListener(src)") [createDragToOpenListener](https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(android.widget.ListPopupWindow,android.view.View))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/widget/ListPopupWindow.html listPopupWindow, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html src )` **This method is deprecated.** Call createDragToOpenListener directly. <br /> |

## Public methods

### createDragToOpenListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static View.OnTouchListener [createDragToOpenListener](https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(java.lang.Object,android.view.View))(Object listPopupWindow, View src)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(android.widget.ListPopupWindow,android.view.View)` that takes in `https://developer.android.com/reference/android/widget/ListPopupWindow.html` instead of `https://developer.android.com/reference/java/lang/Object.html`.

Returns an `https://developer.android.com/reference/android/view/View.OnTouchListener.html` 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 ListPopupWindow.setAnchorView(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 |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html listPopupWindow` | the ListPopupWindow against which to invoke the method |
| `https://developer.android.com/reference/android/view/View.html src` | the view on which the resulting listener will be set |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/View.OnTouchListener.html` | a touch listener that controls drag-to-open behavior, or `null` on unsupported APIs |

### createDragToOpenListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0) Deprecated in [1.15.0](https://developer.android.com/jetpack/androidx/releases/core#1.15.0)

```
@ReplaceWith(expression = "listPopupWindow.createDragToOpenListener(src)")
public static @Nullable View.OnTouchListener [createDragToOpenListener](https://developer.android.com/reference/androidx/core/widget/ListPopupWindowCompat#createDragToOpenListener(android.widget.ListPopupWindow,android.view.View))(
    @NonNull ListPopupWindow listPopupWindow,
    @NonNull View src
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Call createDragToOpenListener directly.

Returns an `https://developer.android.com/reference/android/view/View.OnTouchListener.html` 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 ListPopupWindow.setAnchorView(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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/widget/ListPopupWindow.html listPopupWindow` | the ListPopupWindow against which to invoke the method |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html src` | the view on which the resulting listener will be set |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.OnTouchListener.html` | a touch listener that controls drag-to-open behavior, or `null` on unsupported APIs |