简体   繁体   中英

ApiDemo's: Android Accessibility Node Provider is this working with talkback?

I was exploring the API Demos provided in android sdk, android version > 4.1 . API Demos -> Accessibility -> Accessibility Node Provider

The AccessibilityNodeProvider contains some custom views with Red, Green, Blue colors. As mentioned in the activity , i enabled the talkback and i tried to hover on the views. Talkback couldn't read the colors. Talkback is reading the text available in the activity but not the colors. I was wondering does Talkback reads the colors (custom views) in the activity ?

Thanks in advance

In the package com.example.android.apis.accessibility in the AccessibilityNodeProviderActivity class, find the sendAccessibilityEventForVirtualView() method. You need to set the eventType on the AccessibilityEvent to AccessibilityEvent.TYPE_ANNOUNCEMENT like so:

event.getText().add(virtualView.mText);
event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT);
getParent().requestSendAccessibilityEvent(VirtualSubtreeRootView.this, event);

That should make it announce the text. But it still doesn't highlight the view -- don't know if the expected behaviour is that the node should be highlighted.

I've found this Google Code example to be a better example of speaking text in a node provider setup.

(Old answer below.)

In the AccessibilityNodeProviderActivity class, look at the method sendAccessibilityEventForVirtualView() . You'll see that the text set into the event is the text defined in accessibility_node_provider.xml . You would replace that text with a wording of the different color values to get what you asked for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM