# Customising usage hints for Android TalkBack

In this post, you'll discover how to provide usage hints for visually impaired users and customise built-in ones to suit your app.

TalkBack offers a set of usage hints which are read aloud on actionable Views. An action could be something as simple as a click or a long-click.

Consider the View below (previously seen in an earlier post), which has three inline actions, "reply", "retweet" and "like".

For users with TalkBack enabled, the inline actions are disabled and hidden.

Instead, we provide a dialog (containing these actions) which will open when they click the View.

When the user long-clicks the View, it will trigger the "like" action.

On TalkBack, clicking is achieved by double-tapping the screen while the View is selected. Long-clicking is achieved with a double-tap and hold. TalkBack will announce these as available actions after reading the View's content description.

You can customise this usage hint so it's a bit more explicit than "activate" or "long press" by overriding the label for the click and long click actions.

class BetterLabelsDelegate extends AccessibilityDelegateCompat {

@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);

AccessibilityActionCompat click = new AccessibilityActionCompat(AccessibilityNodeInfo.ACTION_CLICK, "Select an action");
AccessibilityActionCompat longClick = new AccessibilityActionCompat(AccessibilityNodeInfo.ACTION_LONG_CLICK, "Like");

}

}

...

// where you create your View / where you bind it if your custom labels are dependent on the data being bound
ViewCompat.setAccessibilityDelegate(yourTweetView, new BetterLabelsDelegate());


And here's the result:

There were a few bugs around this prior to TalkBack v5.0.2:

• overriding the label for click and long-click would also remove the gesture portion of the text
• the usage hint would only be read aloud if the View was selected using a "next" or "previous" gesture

but these have since been fixed.

Give it a go and, as always, if you have any feedback or questions, feel free to reach out!