Stay organized with collections
Save and categorize content based on your preferences.
OnGlobalFocusChangeListener
interface OnGlobalFocusChangeListener
Known Direct Subclasses
WebView |
A View that displays web pages.
|
|
Interface definition for a callback to be invoked when the focus state within the view tree changes.
Summary
Public methods |
abstract Unit |
Callback method to be invoked when the focus changes in the view tree.
|
Public methods
onGlobalFocusChanged
abstract fun onGlobalFocusChanged(
oldFocus: View!,
newFocus: View!
): Unit
Callback method to be invoked when the focus changes in the view tree. When the view tree transitions from touch mode to non-touch mode, oldFocus is null. When the view tree transitions from non-touch mode to touch mode, newFocus is null. When focus changes in non-touch mode (without transition from or to touch mode) either oldFocus or newFocus can be null.
Parameters |
oldFocus |
View!: The previously focused view, if any. |
newFocus |
View!: The newly focused View, if any. |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ViewTreeObserver.OnGlobalFocusChangeListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnGlobalFocusChangeListener\n===========================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/ViewTreeObserver.OnGlobalFocusChangeListener \"View this page in Java\") \n\n```\ninterface OnGlobalFocusChangeListener\n```\n\n|----------------------------------------------------------------|\n| [android.view.ViewTreeObserver.OnGlobalFocusChangeListener](#) |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [WebView](../webkit/WebView.html#) |------------------------------------|---------------------------------| | [WebView](../webkit/WebView.html#) | A View that displays web pages. | |\n\nInterface definition for a callback to be invoked when the focus state within the view tree changes.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onGlobalFocusChanged](#onGlobalFocusChanged(android.view.View,%20android.view.View))`(`oldFocus:` `[View](/reference/kotlin/android/view/View)!`, `newFocus:` `[View](/reference/kotlin/android/view/View)!`)` Callback method to be invoked when the focus changes in the view tree. |\n\nPublic methods\n--------------\n\n### onGlobalFocusChanged\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onGlobalFocusChanged(\n oldFocus: View!, \n newFocus: View!\n): Unit\n```\n\nCallback method to be invoked when the focus changes in the view tree. When the view tree transitions from touch mode to non-touch mode, oldFocus is null. When the view tree transitions from non-touch mode to touch mode, newFocus is null. When focus changes in non-touch mode (without transition from or to touch mode) either oldFocus or newFocus can be null.\n\n| Parameters ||\n|------------|------------------------------------------------------------------------------------|\n| `oldFocus` | [View](/reference/kotlin/android/view/View)!: The previously focused view, if any. |\n| `newFocus` | [View](/reference/kotlin/android/view/View)!: The newly focused View, if any. |"]]