# PoolingContainer

Added in 1.0.0

*** ** * ** ***


```
public final class PoolingContainer
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).addPoolingContainerListener(androidx.customview.poolingcontainer.PoolingContainerListener)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener listener )` Add a callback for when this View should dispose its resources. |
| `static final void` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).callPoolingContainerOnRelease()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Calls `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener#onRelease()` on any `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener`s attached to this View or any of its children. |
| `static final void` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.ViewGroup).callPoolingContainerOnReleaseForChildren()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/ViewGroup.html receiver)` Calls `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener#onRelease()` on any `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener`s attached to any of its children (not including the `ViewGroup` itself) |
| `static final boolean` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).isPoolingContainer()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Whether this View is a container that manages the lifecycle of its child Views. |
| `static final boolean` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).isWithinPoolingContainer()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Whether one of this View's ancestors has `isPoolingContainer` set to `true` |
| `static final void` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).removePoolingContainerListener(androidx.customview.poolingcontainer.PoolingContainerListener)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener listener )` Remove a callback that was previously added by `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).addPoolingContainerListener(androidx.customview.poolingcontainer.PoolingContainerListener)` |
| `static final void` | `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainer#(android.view.View).setPoolingContainer(kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, boolean value)` Whether this View is a container that manages the lifecycle of its child Views. |

## Public methods

### addPoolingContainerListener

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+function:addPoolingContainerListener) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final void addPoolingContainerListener(
    @NonNull View receiver,
    @NonNull PoolingContainerListener listener
)
```

Add a callback for when this View should dispose its resources.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver` | the child view to receive callbacks regarding |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener listener` | the listener that produces onRelease callbacks, triggering resource disposal |

### callPoolingContainerOnRelease

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+function:callPoolingContainerOnRelease) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final void callPoolingContainerOnRelease(@NonNull View receiver)
```

Calls `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener#onRelease()` on any `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener`s attached to this View or any of its children.

At the point when this is called, the View should be detached from the window.

### callPoolingContainerOnReleaseForChildren

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+function:callPoolingContainerOnReleaseForChildren) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final void callPoolingContainerOnReleaseForChildren(@NonNull ViewGroup receiver)
```

Calls `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener#onRelease()` on any `https://developer.android.com/reference/androidx/customview/poolingcontainer/PoolingContainerListener`s attached to any of its children (not including the `ViewGroup` itself)

At the point when this is called, the View should be detached from the window.

### isPoolingContainer

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+symbol:isPoolingContainer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final boolean isPoolingContainer(@NonNull View receiver)
```

Whether this View is a container that manages the lifecycle of its child Views.

Any View that sets this to `true` must call `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).callPoolingContainerOnRelease()` on child Views before they are discarded and may possibly not be used in the future. This includes when the view itself is detached from the window, unless it is being held for possible later reattachment and its children should not release their resources.

**Warning: Failure to call `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).callPoolingContainerOnRelease()` when a View is removed from the hierarchy and discarded is likely to result in memory leaks!**

### isWithinPoolingContainer

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+symbol:isWithinPoolingContainer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final boolean isWithinPoolingContainer(@NonNull View receiver)
```

Whether one of this View's ancestors has `isPoolingContainer` set to `true`

### removePoolingContainerListener

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+function:removePoolingContainerListener) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final void removePoolingContainerListener(
    @NonNull View receiver,
    @NonNull PoolingContainerListener listener
)
```

Remove a callback that was previously added by `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).addPoolingContainerListener(androidx.customview.poolingcontainer.PoolingContainerListener)`

### setPoolingContainer

Artifact: [androidx.customview:customview-poolingcontainer](https://developer.android.com/jetpack/androidx/releases/customview) [View Source](https://cs.android.com/search?q=file:androidx/customview/poolingcontainer/PoolingContainer.kt+symbol:isPoolingContainer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/customview#1.0.0)

```
public static final void setPoolingContainer(@NonNull View receiver, boolean value)
```

Whether this View is a container that manages the lifecycle of its child Views.

Any View that sets this to `true` must call `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).callPoolingContainerOnRelease()` on child Views before they are discarded and may possibly not be used in the future. This includes when the view itself is detached from the window, unless it is being held for possible later reattachment and its children should not release their resources.

**Warning: Failure to call `https://developer.android.com/reference/androidx/customview/poolingcontainer/package-summary#(android.view.View).callPoolingContainerOnRelease()` when a View is removed from the hierarchy and discarded is likely to result in memory leaks!**