# ExploreByTouchHelper

# ExploreByTouchHelper

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

*** ** * ** ***

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


```
abstract class ExploreByTouchHelper : AccessibilityDelegateCompat
```

<br />

|---|---|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                                      |||
| ↳ | [androidx.core.view.AccessibilityDelegateCompat](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat)      ||
|   | ↳ | [androidx.customview.widget.ExploreByTouchHelper](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper) |

*** ** * ** ***

ExploreByTouchHelper is a utility class for implementing accessibility support in custom [View](https://developer.android.com/reference/android/view/View.html)s that represent a collection of View-like logical items. It extends [AccessibilityNodeProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeProviderCompat) and simplifies many aspects of providing information to accessibility services and managing accessibility focus.

Clients should override abstract methods on this class and attach it to the host view using [setAccessibilityDelegate](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#setAccessibilityDelegate(android.view.View,androidx.core.view.AccessibilityDelegateCompat)).

The host view should also override the events in the following code snippet so that the view's logical items are detected properly by the framework:  

```kotlin
class MyCustomView extends View {
    private MyExploreByTouchHelper mExploreByTouchHelper;

    public MyCustomView(Context context, ...) {
        ...
        mExploreByTouchHelper = new MyExploreByTouchHelper(this);
        ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
    }

    @Override
    public boolean dispatchHoverEvent(MotionEvent event) {
      return mExploreByTouchHelper.dispatchHoverEvent(event)
          || super.dispatchHoverEvent(event);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
      return mExploreByTouchHelper.dispatchKeyEvent(event)
          || super.dispatchKeyEvent(event);
    }

    @Override
    public void onFocusChanged(boolean gainFocus, int direction,
        Rect previouslyFocusedRect) {
      super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
      mExploreByTouchHelper.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    }
}
```

## Summary

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [HOST_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#HOST_ID())` = -1` Virtual node identifier value for the host view's node.         |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [INVALID_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#INVALID_ID())` = -2147483648` Virtual node identifier value for invalid nodes. |

|                                                                                                                                                            ### Public constructors                                                                                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ExploreByTouchHelper](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#ExploreByTouchHelper(android.view.View))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`)` Constructs a new helper that can expose a virtual view hierarchy for the specified host view. |

|                                                                 ### Public functions                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                   | [clearKeyboardFocusForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#clearKeyboardFocusForVirtualView(int))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Attempts to clear keyboard focus from a virtual view.                                                                                                                                                                                                                                                                                                                                                                          |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                   | [dispatchHoverEvent](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#dispatchHoverEvent(android.view.MotionEvent))`(event: `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)`)` Delegates hover events from the host view.                                                                                                                                                                                                                                                                                                                                                                                           |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                   | [dispatchKeyEvent](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#dispatchKeyEvent(android.view.KeyEvent))`(event: `[KeyEvent](https://developer.android.com/reference/android/view/KeyEvent.html)`)` Delegates key events from the host view.                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                           | [getAccessibilityFocusedVirtualViewId](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getAccessibilityFocusedVirtualViewId())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [AccessibilityNodeProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeProviderCompat)`!` | [getAccessibilityNodeProvider](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getAccessibilityNodeProvider(android.view.View))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`!)` Gets the provider for managing a virtual view hierarchy rooted at this View and reported to [AccessibilityService](https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html)s that explore the window content.                                                                                                                                                                                  |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                           | ~~[getFocusedVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getFocusedVirtualView())~~`()` **This function is deprecated.** Use [getAccessibilityFocusedVirtualViewId](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getAccessibilityFocusedVirtualViewId()). <br />                                                                                                                                                                                                                                                                                                                      |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                           | [getKeyboardFocusedVirtualViewId](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getKeyboardFocusedVirtualViewId())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [invalidateRoot](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#invalidateRoot())`()` Notifies the accessibility framework that the properties of the parent view have changed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [invalidateVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#invalidateVirtualView(int))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies the accessibility framework that the properties of a particular item have changed.                                                                                                                                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [invalidateVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#invalidateVirtualView(int,int))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, changeTypes: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Notifies the accessibility framework that the properties of a particular item have changed.                                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [onFocusChanged](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onFocusChanged(boolean,int,android.graphics.Rect))`(` ` gainFocus: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` direction: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` previouslyFocusedRect: `[Rect](https://developer.android.com/reference/android/graphics/Rect.html)`?` `)` Delegates focus changes from the host view.                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [onInitializeAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`!, event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`!)` Initializes an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the the host View which is the event source.                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat))`(` ` host: `[View](https://developer.android.com/reference/android/view/View.html)`!,` ` info: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat)`!` `)` Initializes an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the host view. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                   | [requestKeyboardFocusForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#requestKeyboardFocusForVirtualView(int))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Attempts to give keyboard focus to a virtual view.                                                                                                                                                                                                                                                                                                                                                                         |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                   | [sendEventForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#sendEventForVirtualView(int,int))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, eventType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Populates an event of the specified type with information about an item and attempts to send it up through the view hierarchy.                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                         | [setBoundsInScreenFromBoundsInParent](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#setBoundsInScreenFromBoundsInParent(androidx.core.view.accessibility.AccessibilityNodeInfoCompat,android.graphics.Rect))`(` ` node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat)`,` ` boundsInParent: `[Rect](https://developer.android.com/reference/android/graphics/Rect.html) `)` Calculates and assigns screen-relative bounds based on bounds in parent.                                                                                                      |

|                                    ### Protected functions                                     |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)         | [getVirtualViewAt](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getVirtualViewAt(float,float))`(x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, y: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Provides a mapping between view-relative coordinates and logical items.                                                                                                                                                                                                                                                                                       |
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [getVisibleVirtualViews](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getVisibleVirtualViews(java.util.List<java.lang.Integer>))`(virtualViewIds: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`!>!)` Populates a list with the view's visible items.                                                                                                                                                   |
| `abstract `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [onPerformActionForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPerformActionForVirtualView(int,int,android.os.Bundle))`(` ` virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` action: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` arguments: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`?` `)` Performs the specified accessibility action on the item associated with the virtual view identifier.                                                                                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                  | [onPopulateEventForHost](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateEventForHost(android.view.accessibility.AccessibilityEvent))`(event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`)` Populates an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the host view.                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                  | [onPopulateEventForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateEventForVirtualView(int,android.view.accessibility.AccessibilityEvent))`(` ` virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) `)` Populates an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the specified item.                                                                 |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                  | [onPopulateNodeForHost](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForHost(androidx.core.view.accessibility.AccessibilityNodeInfoCompat))`(node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat)`)` Populates an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the host view.                                                                                                                              |
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat))`(` ` virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) `)` Populates an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the specified item. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                  | [onVirtualViewKeyboardFocusChanged](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onVirtualViewKeyboardFocusChanged(int,boolean))`(virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, hasFocus: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Called when the focus state of a virtual view changes.                                                                                                                                                                                                                                                   |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From [androidx.core.view.AccessibilityDelegateCompat](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat) |-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [dispatchPopulateAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#dispatchPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`, event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`)` Dispatches an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) to the host [View](https://developer.android.com/reference/android/view/View.html) first and then to its children for adding their text content to the event.                                                                                  | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [onPopulateAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#onPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`, event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`)` Gives a chance to the host View to populate the accessibility event with its text content.                                                                                                                                                                                                                                                                                                | | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [onRequestSendAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#onRequestSendAccessibilityEvent(android.view.ViewGroup,android.view.View,android.view.accessibility.AccessibilityEvent))`(` ` host: `[ViewGroup](https://developer.android.com/reference/android/view/ViewGroup.html)`,` ` child: `[View](https://developer.android.com/reference/android/view/View.html)`,` ` event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) `)` Called when a child of the host View has requested sending an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) and gives an opportunity to the parent (the host) to augment the event. | | [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [performAccessibilityAction](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#performAccessibilityAction(android.view.View,int,android.os.Bundle))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`, action: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, args: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`?)` Performs the specified accessibility action on the view.                                                                                                                                                                                                                                                                                                               | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [sendAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#sendAccessibilityEvent(android.view.View,int))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`, eventType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sends an accessibility event of the given type.                                                                                                                                                                                                                                                                                                                                                                                                                                  | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [sendAccessibilityEventUnchecked](https://developer.android.com/reference/kotlin/androidx/core/view/AccessibilityDelegateCompat#sendAccessibilityEventUnchecked(android.view.View,android.view.accessibility.AccessibilityEvent))`(host: `[View](https://developer.android.com/reference/android/view/View.html)`, event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`)` Sends an accessibility event.                                                                                                                                                                                                                                                                                                                                                       | |

## Constants

### HOST_ID

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

```
const val HOST_ID = -1: Int
```

Virtual node identifier value for the host view's node.  

### INVALID_ID

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

```
const val INVALID_ID = -2147483648: Int
```

Virtual node identifier value for invalid nodes.  

## Public constructors

### ExploreByTouchHelper

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

```
ExploreByTouchHelper(host: View)
```

Constructs a new helper that can expose a virtual view hierarchy for the specified host view.  

|                                   Parameters                                   |
|--------------------------------------------------------------------------------|-------------------------------------------------------------|
| `host: `[View](https://developer.android.com/reference/android/view/View.html) | view whose virtual view hierarchy is exposed by this helper |

## Public functions

### clearKeyboardFocusForVirtualView

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

```
fun clearKeyboardFocusForVirtualView(virtualViewId: Int): Boolean
```

Attempts to clear keyboard focus from a virtual view.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view from which to clear keyboard focus |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | whether this virtual view actually cleared keyboard focus |

### dispatchHoverEvent

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

```
fun dispatchHoverEvent(event: MotionEvent): Boolean
```

Delegates hover events from the host view.

Dispatches hover [MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html)s to the virtual view hierarchy when the Explore by Touch feature is enabled.

This method should be called by overriding the host view's [dispatchHoverEvent](https://developer.android.com/reference/android/view/View.html#dispatchHoverEvent(android.view.MotionEvent)) method:  

```kotlin
@Override
public boolean dispatchHoverEvent(MotionEvent event) {
  return mHelper.dispatchHoverEvent(this, event)
      || super.dispatchHoverEvent(event);
}
```  

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------|
| `event: `[MotionEvent](https://developer.android.com/reference/android/view/MotionEvent.html) | The hover event to dispatch to the virtual view hierarchy. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether the hover event was handled. |

### dispatchKeyEvent

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

```
fun dispatchKeyEvent(event: KeyEvent): Boolean
```

Delegates key events from the host view.

This method should be called by overriding the host view's [dispatchKeyEvent](https://developer.android.com/reference/android/view/View.html#dispatchKeyEvent(android.view.KeyEvent)) method:  

```kotlin
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  return mHelper.dispatchKeyEvent(event)
      || super.dispatchKeyEvent(event);
}
```  

### getAccessibilityFocusedVirtualViewId

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

```
fun getAccessibilityFocusedVirtualViewId(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view that has accessibility focus or [INVALID_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#INVALID_ID()) if no virtual view has accessibility focus |

### getAccessibilityNodeProvider

```
fun getAccessibilityNodeProvider(host: View!): AccessibilityNodeProviderCompat!
```

Gets the provider for managing a virtual view hierarchy rooted at this View and reported to [AccessibilityService](https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html)s that explore the window content.

The default implementation behaves as [ViewCompat#getAccessibilityNodeProvider(View)](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#getAccessibilityNodeProvider(android.view.View)) for the case of no accessibility delegate been set.  

|                                                                        Returns                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| [AccessibilityNodeProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeProviderCompat)`!` | The provider. |

|                                                                      See also                                                                      |
|----------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [AccessibilityNodeProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeProviderCompat) |   |

### getFocusedVirtualView

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

```
fun [getFocusedVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getFocusedVirtualView())(): Int
```
| **This function is deprecated.**   
|
| Use [getAccessibilityFocusedVirtualViewId](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#getAccessibilityFocusedVirtualViewId()).

Returns the virtual view ID for the currently accessibility focused item.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view that has accessibility focus or [INVALID_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#INVALID_ID()) if no virtual view has accessibility focus |

### getKeyboardFocusedVirtualViewId

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

```
fun getKeyboardFocusedVirtualViewId(): Int
```  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view that has keyboard focus or [INVALID_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#INVALID_ID()) if no virtual view has keyboard focus |

### invalidateRoot

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

```
fun invalidateRoot(): Unit
```

Notifies the accessibility framework that the properties of the parent view have changed.

You **must** call this method after adding or removing items from the parent view.  

### invalidateVirtualView

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

```
fun invalidateVirtualView(virtualViewId: Int): Unit
```

Notifies the accessibility framework that the properties of a particular item have changed.

You **must** call this method after changing any of the properties set in [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)).  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the virtual view id to invalidate, or [HOST_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#HOST_ID()) to invalidate the root view |

|                                                                        See also                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [invalidateVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#invalidateVirtualView(int,int)) |   |

### invalidateVirtualView

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

```
fun invalidateVirtualView(virtualViewId: Int, changeTypes: Int): Unit
```

Notifies the accessibility framework that the properties of a particular item have changed.

You **must** call this method after changing any of the properties set in [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)).  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the virtual view id to invalidate, or [HOST_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#HOST_ID()) to invalidate the root view                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `changeTypes: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | the bit mask of change types. May be `0` for the default (undefined) change type or one or more of: - [CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityEventCompat#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION()) - [CONTENT_CHANGE_TYPE_SUBTREE](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityEventCompat#CONTENT_CHANGE_TYPE_SUBTREE()) - [CONTENT_CHANGE_TYPE_TEXT](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityEventCompat#CONTENT_CHANGE_TYPE_TEXT()) - [CONTENT_CHANGE_TYPE_UNDEFINED](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityEventCompat#CONTENT_CHANGE_TYPE_UNDEFINED()) |

### onFocusChanged

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

```
fun onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect?
): Unit
```

Delegates focus changes from the host view.

This method should be called by overriding the host view's [onFocusChanged](https://developer.android.com/reference/android/view/View.html#onFocusChanged(boolean, int, android.graphics.Rect)) method:  

```kotlin
@Override
public boolean onFocusChanged(boolean gainFocus, int direction,
    Rect previouslyFocusedRect) {
  super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
  mHelper.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
```  

### onInitializeAccessibilityEvent

```
fun onInitializeAccessibilityEvent(host: View!, event: AccessibilityEvent!): Unit
```

Initializes an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the the host View which is the event source.

The default implementation behaves as [ViewCompat#onInitalizeAccessibilityEvent(View v, AccessibilityEvent event)](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)) for the case of no accessibility delegate been set.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| `host: `[View](https://developer.android.com/reference/android/view/View.html)`!`                                            | The View hosting the delegate. |
| `event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html)`!` | The event to initialize.       |

|                                                                                                    See also                                                                                                    |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| [onInitializeAccessibilityEvent](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)) | ViewCompat#onInitializeAccessibilityEvent(View, AccessibilityEvent) |

### onInitializeAccessibilityNodeInfo

```
fun onInitializeAccessibilityNodeInfo(
    host: View!,
    info: AccessibilityNodeInfoCompat!
): Unit
```

Initializes an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the host view.

The default implementation behaves as [ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)) for the case of no accessibility delegate been set.  

|                                                                      Parameters                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| `host: `[View](https://developer.android.com/reference/android/view/View.html)`!`                                                                     | The View hosting the delegate. |
| `info: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat)`!` | The instance to initialize.    |

|                                                                                                              See also                                                                                                               |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [onInitializeAccessibilityNodeInfo](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)) | ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) |

### requestKeyboardFocusForVirtualView

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

```
fun requestKeyboardFocusForVirtualView(virtualViewId: Int): Boolean
```

Attempts to give keyboard focus to a virtual view.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view on which to place keyboard focus |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | whether this virtual view actually took keyboard focus |

### sendEventForVirtualView

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

```
fun sendEventForVirtualView(virtualViewId: Int, eventType: Int): Boolean
```

Populates an event of the specified type with information about an item and attempts to send it up through the view hierarchy.

You should call this method after performing a user action that normally fires an accessibility event, such as clicking on an item.  

```kotlin
public void performItemClick(T item) {
  ...
  sendEventForVirtualViewId(item.id, AccessibilityEvent.TYPE_VIEW_CLICKED);
}
```  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the identifier of the virtual view for which to send an event |
| `eventType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)     | the type of event to send                                     |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true` if the event was sent successfully, `false` otherwise |

### setBoundsInScreenFromBoundsInParent

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

```
fun setBoundsInScreenFromBoundsInParent(
    node: AccessibilityNodeInfoCompat,
    boundsInParent: Rect
): Unit
```

Calculates and assigns screen-relative bounds based on bounds in parent. Instead of calling the deprecated [setBoundsInParent](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setBoundsInParent(android.graphics.Rect)), it provides a convenient method to calculate and assign [setBoundsInScreen](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setBoundsInScreen(android.graphics.Rect)) based on `boundsInParent`.  

|                                                                     Parameters                                                                     |
|----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| `node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) | The node to populate                             |
| `boundsInParent: `[Rect](https://developer.android.com/reference/android/graphics/Rect.html)                                                       | The node bounds in the viewParent's coordinates. |

## Protected functions

### getVirtualViewAt

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

```
protected abstract fun getVirtualViewAt(x: Float, y: Float): Int
```

Provides a mapping between view-relative coordinates and logical items.  

|                                      Parameters                                      |
|--------------------------------------------------------------------------------------|--------------------------------|
| `x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The view-relative x coordinate |
| `y: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The view-relative y coordinate |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | virtual view identifier for the logical item under coordinates (x,y) or [HOST_ID](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#HOST_ID()) if there is no item at the given coordinates |

### getVisibleVirtualViews

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

```
protected abstract fun getVisibleVirtualViews(virtualViewIds: (Mutable)List<Int!>!): Unit
```

Populates a list with the view's visible items. The ordering of items within `virtualViewIds` specifies order of accessibility focus traversal.  

|                                                                                                                                               Parameters                                                                                                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| `virtualViewIds: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`!>!` | The list to populate with visible items |

### onPerformActionForVirtualView

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

```
protected abstract fun onPerformActionForVirtualView(
    virtualViewId: Int,
    action: Int,
    arguments: Bundle?
): Boolean
```

Performs the specified accessibility action on the item associated with the virtual view identifier. See [performAction](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#performAction(int,android.os.Bundle)) for more information.

Implementations **must** handle any actions added manually in [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)).

The helper class automatically handles focus management resulting from [ACTION_ACCESSIBILITY_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_ACCESSIBILITY_FOCUS()) and [ACTION_CLEAR_ACCESSIBILITY_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_CLEAR_ACCESSIBILITY_FOCUS()) actions.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The virtual view identifier of the item on which to perform the action |
| `action: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)        | The accessibility action to perform                                    |
| `arguments: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`?`     | (Optional) A bundle with additional arguments, or null                 |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if the action was performed |

### onPopulateEventForHost

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

```
protected fun onPopulateEventForHost(event: AccessibilityEvent): Unit
```

Populates an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the host view.

The default implementation is a no-op.  

|                                                        Parameters                                                         |
|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| `event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) | the event to populate with information about the host view |

### onPopulateEventForVirtualView

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

```
protected fun onPopulateEventForVirtualView(
    virtualViewId: Int,
    event: AccessibilityEvent
): Unit
```

Populates an [AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) with information about the specified item.

The helper class automatically populates the following fields based on the values set by [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)), but implementations may optionally override them:

- event text, see [getText](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#getText())
- content description, see [setContentDescription](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#setContentDescription(java.lang.CharSequence))
- scrollability, see [setScrollable](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#setScrollable(boolean))
- password state, see [setPassword](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#setPassword(boolean))
- enabled state, see [setEnabled](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#setEnabled(boolean))
- checked state, see [setChecked](https://developer.android.com/reference/android/view/accessibility/AccessibilityRecord.html#setChecked(boolean))

The following required fields are automatically populated by the helper class and may not be overridden:

- item class name, set to the value used in [onPopulateNodeForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateNodeForVirtualView(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat))
- package name, set to the package of the host view's [Context](https://developer.android.com/reference/android/content/Context.html), see [setPackageName](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html#setPackageName(java.lang.CharSequence))
- event source, set to the host view and virtual view identifier, see [setSource](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityRecordCompat#setSource(android.view.accessibility.AccessibilityRecord,android.view.View,int))

|                                                        Parameters                                                         |
|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                              | The virtual view id for the item for which to populate the event |
| `event: `[AccessibilityEvent](https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html) | The event to populate                                            |

### onPopulateNodeForHost

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

```
protected fun onPopulateNodeForHost(node: AccessibilityNodeInfoCompat): Unit
```

Populates an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the host view.

The default implementation is a no-op.  

|                                                                     Parameters                                                                     |
|----------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| `node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) | the node to populate with information about the host view |

### onPopulateNodeForVirtualView

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

```
protected abstract fun onPopulateNodeForVirtualView(
    virtualViewId: Int,
    node: AccessibilityNodeInfoCompat
): Unit
```

Populates an [AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) with information about the specified item.

Implementations **must** populate the following required fields:

- event text, see [setText](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setText(java.lang.CharSequence)) or [setContentDescription](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setContentDescription(java.lang.CharSequence))
- bounds in screen coordinates, see [setBoundsInScreen](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setBoundsInScreen(android.graphics.Rect)) and [(AccessibilityNodeInfoCompat, Rect)](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#setBoundsInScreenFromBoundsInParent(androidx.core.view.accessibility.AccessibilityNodeInfoCompat,android.graphics.Rect))

The helper class automatically populates the following fields with default values, but implementations may optionally override them:

- enabled state, set to `true`, see [setEnabled](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setEnabled(boolean))
- keyboard focusability, set to `true`, see [setFocusable](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setFocusable(boolean))
- item class name, set to `android.view.View`, see [setClassName](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setClassName(java.lang.CharSequence))

The following required fields are automatically populated by the helper class and may not be overridden:

- package name, identical to the package name set by [onPopulateEventForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateEventForVirtualView(int,android.view.accessibility.AccessibilityEvent)), see [setPackageName](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setPackageName(java.lang.CharSequence))
- node source, identical to the event source set in [onPopulateEventForVirtualView](https://developer.android.com/reference/kotlin/androidx/customview/widget/ExploreByTouchHelper#onPopulateEventForVirtualView(int,android.view.accessibility.AccessibilityEvent)), see [setSource](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setSource(android.view.View,int))
- parent view, set to the host view, see [setParent](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setParent(android.view.View))
- visibility, computed based on parent-relative bounds, see [setVisibleToUser](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setVisibleToUser(boolean))
- accessibility focus, computed based on internal helper state, see [setAccessibilityFocused](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setAccessibilityFocused(boolean))
- keyboard focus, computed based on internal helper state, see [setFocused](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#setFocused(boolean))

Additionally, the helper class automatically handles keyboard focus and accessibility focus management by adding the appropriate [ACTION_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_FOCUS()), [ACTION_CLEAR_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_CLEAR_FOCUS()), [ACTION_ACCESSIBILITY_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_ACCESSIBILITY_FOCUS()), or [ACTION_CLEAR_ACCESSIBILITY_FOCUS](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#ACTION_CLEAR_ACCESSIBILITY_FOCUS()) actions. Implementations must **never** manually add these actions.

The helper class also automatically modifies parent- and screen-relative bounds to reflect the portion of the item visible within its parent.  

|                                                                     Parameters                                                                     |
|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                       | The virtual view identifier of the item for which to populate the node |
| `node: `[AccessibilityNodeInfoCompat](https://developer.android.com/reference/kotlin/androidx/core/view/accessibility/AccessibilityNodeInfoCompat) | The node to populate                                                   |

### onVirtualViewKeyboardFocusChanged

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

```
protected fun onVirtualViewKeyboardFocusChanged(virtualViewId: Int, hasFocus: Boolean): Unit
```

Called when the focus state of a virtual view changes.  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|-------------------------------------------------|
| `virtualViewId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)    | the virtual view identifier                     |
| `hasFocus: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true` if the view has focus, `false` otherwise |