7
我有一个针对事件类型“typeViewTextSelectionChanged”运行的辅助功能服务。我能赶上,只要用户选择任何文本此事件触发,但我如何得到AccessibilityNodeInfo或AccessibilityEvent选定的文本内容对象如何从AccessibilityNodeInfo获取所选文本
我有一个针对事件类型“typeViewTextSelectionChanged”运行的辅助功能服务。我能赶上,只要用户选择任何文本此事件触发,但我如何得到AccessibilityNodeInfo或AccessibilityEvent选定的文本内容对象如何从AccessibilityNodeInfo获取所选文本
下面的走了进去,
onAccessibilityEvent(AccessibilityEvent event){}
然后,
//Get the source
AccessibilityNodeInfo source = event.getSource();
//Grab the parent of the view that fired the event.
AccessibilityNodeInfo rowNode = getListItemNodeInfo(source);
//Using this parent, get references to child node, the selected text
AccessibilityNodeInfo textNode = rowNode.getChild(0);
//Get the text values
String text = textNode.getText();
OR
或者在你的情况下,以下应该工作得很好。因为它是一个“typeViewTextSelectionChanged”事件,显然它来自EditText。
String text=event.getText();
我似乎无法找到任何getListItemNodeInfo文件,请您链接到你见过? – Jayce