Yes, it is absolutely possible!
Overriding the onInitializeAccessibilityNodeInfo
If you have a custom view, you can override the onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) method and add an action with the ACTION_CLICK identifier to override the label:
@Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.addAction( new AccessibilityNodeInfo.AccessibilityAction( AccessibilityNodeInfo.ACTION_CLICK, "play video" ) ); }
If this view has a click listener, then by adding this new Action you will override the default label, so TalkBack will say โDouble-clickโ instead.
This is only available in API 21 โ what if you want something that worked in a lower version of the API, or want to set a custom usage hint on a custom view? You can use ViewCompat and AccessibilityDelegateCompat !
Use AccessibilityDelegate instead
This is very similar - you can override the equivalent method in a custom AccessibilityDelegate, which you extend:
public static class PlayVideoAccessibilityDelegate extends AccessibilityDelegateCompat { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) { super.onInitializeAccessibilityNodeInfo(host, info); info.addAction( new AccessibilityNodeInfoCompat.AccessibilityActionCompat( AccessibilityNodeInfoCompat.ACTION_CLICK, "play video" ) ); } }
then to use it, you set the delegate using ViewCompat :
ViewCompat.setAccessibilityDelegate(playButton, new PlayVideoAccessibilityDelegate());
Using accessibilitools
Novoda has a utility library that will help with access to Android. This includes some tools to help establish usage tips:
UsageHintsAccessibilityDelegate delegate = new UsageHintsAccessibilityDelegate(resources); delegate.setClickLabel("play video"); ViewCompat.setAccesibilityDelegate(playButton, delegate);
I wrote a block package which is a review of accessibilitools (I am also the author of the library).