问题
I have an application requirement to announce text in a list view. The list view item gets added at run time. I have to announce them one by one. I searched on google and in android docs, but I could not reach there.
Please help me, how to know accessibility services finished reading the text?
Thanks :)
回答1:
Simple answer... don't do it this way! This is silliness. Just use the accessibility features available to you and let TalkBack (or other potential screen reader) manage it for you. Just use this utility function.
public static void announceForAccessibility(Context context, String message) {
AccessibilityManager manager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (manager.isEnabled()) {
AccessibilityEvent e = AccessibilityEvent.obtain();
e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
e.setClassName(context.getClass().getName());
e.setPackageName(context.getPackageName());
e.getText().add(message);
manager.sendAccessibilityEvent(e);
}
}
来源:https://stackoverflow.com/questions/42782169/is-there-any-callback-or-anything-any-parameter-in-event-or-nodeinfo-to-know-a