# RecyclerView.OnChildAttachStateChangeListener

# RecyclerView.OnChildAttachStateChangeListener

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.OnChildAttachStateChangeListener "View this page in Java")

<br />

```
interface RecyclerView.OnChildAttachStateChangeListener
```

<br />

Known direct subclasses  
[ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper)  

|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| [ItemTouchHelper](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ItemTouchHelper) | This is a utility class to add swipe to dismiss and drag \&drop support to RecyclerView. |

*** ** * ** ***

A Listener interface that can be attached to a RecylcerView to get notified whenever a ViewHolder is attached to or detached from RecyclerView.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onChildViewAttachedToWindow](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnChildAttachStateChangeListener#onChildViewAttachedToWindow(android.view.View))`(view: `[View](https://developer.android.com/reference/android/view/View.html)`)` Called when a view is attached to the RecyclerView.   |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onChildViewDetachedFromWindow](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView.OnChildAttachStateChangeListener#onChildViewDetachedFromWindow(android.view.View))`(view: `[View](https://developer.android.com/reference/android/view/View.html)`)` Called when a view is detached from RecyclerView. |

## Public functions

### onChildViewAttachedToWindow

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onChildViewAttachedToWindow(view: View): Unit
```

Called when a view is attached to the RecyclerView.  

|                                   Parameters                                   |
|--------------------------------------------------------------------------------|------------------------------------------------|
| `view: `[View](https://developer.android.com/reference/android/view/View.html) | The View which is attached to the RecyclerView |

### onChildViewDetachedFromWindow

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/recyclerview#1.0.0)  

```
fun onChildViewDetachedFromWindow(view: View): Unit
```

Called when a view is detached from RecyclerView.  

|                                   Parameters                                   |
|--------------------------------------------------------------------------------|--------------------------------------------------------|
| `view: `[View](https://developer.android.com/reference/android/view/View.html) | The View which is being detached from the RecyclerView |