Accessibility action on Android
Accessibility actions provide alternative ways for users of assistive technologies to perform actions. For users of switch control it can be difficult to use drag-and-drop functionality. This functionality can be made more accessible by providing accessibility actions to move items up and down.
Accessibility action - Android
On Android, you can add custom actions for assistive technologies using the ViewCompat.addAccessibilityAction
helper method.
You can also use the addAction
method of AccessibilityNodeInfoCompat
to override labels for default actions.
// Add custom action
ViewCompat.addAccessibilityAction(view, "Add bookmark") { view, arguments ->
// Bookmark logic
true
}
// Override click action label
ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() {
@Override
public void onInitializeAccessibilityNodeInfo(
View host,
AccessibilityNodeInfoCompat info)
{
super.onInitializeAccessibilityNodeInfo(host, info)
AccessibilityActionCompat action = new AccessibilityActionCompat(
AccessibilityNodeInfoCompat.ACTION_CLICK,
"Add bookmark"
)
info.addAction(action)
}
})