Stay organized with collections
Save and categorize content based on your preferences.
OnWindowAttachListener
interface OnWindowAttachListener
Interface definition for a callback to be invoked when the view hierarchy is attached to and detached from its window.
Summary
Public methods |
abstract Unit |
Callback method to be invoked when the view hierarchy is attached to a window
|
abstract Unit |
Callback method to be invoked when the view hierarchy is detached from a window
|
Public methods
onWindowAttached
abstract fun onWindowAttached(): Unit
Callback method to be invoked when the view hierarchy is attached to a window
onWindowDetached
abstract fun onWindowDetached(): Unit
Callback method to be invoked when the view hierarchy is detached from a window
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ViewTreeObserver.OnWindowAttachListener\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnWindowAttachListener\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/ViewTreeObserver.OnWindowAttachListener \"View this page in Java\") \n\n```\ninterface OnWindowAttachListener\n```\n\n|-----------------------------------------------------------|\n| [android.view.ViewTreeObserver.OnWindowAttachListener](#) |\n\nInterface definition for a callback to be invoked when the view hierarchy is attached to and detached from its window.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onWindowAttached](#onWindowAttached())`()` Callback method to be invoked when the view hierarchy is attached to a window |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onWindowDetached](#onWindowDetached())`()` Callback method to be invoked when the view hierarchy is detached from a window |\n\nPublic methods\n--------------\n\n### onWindowAttached\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onWindowAttached(): Unit\n```\n\nCallback method to be invoked when the view hierarchy is attached to a window \n\n### onWindowDetached\n\nAdded in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onWindowDetached(): Unit\n```\n\nCallback method to be invoked when the view hierarchy is detached from a window"]]