gpt4 book ai didi

android - 在辅助功能模式下,我想覆盖 TextView 的 TalkBack

转载 作者:行者123 更新时间:2023-11-29 22:20:49 25 4
gpt4 key购买 nike

我目前有一个 ListView,该列表的每个元素至少包含两个 TextView。我正在为我的应用程序添加辅助功能,所以每当我关注某个列表元素时,它都会读出每个 TextView 中的文本。

现在,我正在向它发送一个 TalkBack 事件,但在它完成之后,它会再次读出 TextView。我希望它只完成我的 TalkBack 事件,而不是其他任何事情。

有人知道怎么做吗?

提前致谢!

最佳答案

当然,只需覆盖 View.dispatchPopulateAccessibilityEvent .

来自文档(强调我的):

A typical implementation will call onPopulateAccessibilityEvent(AccessibilityEvent) on the this view and then call the dispatchPopulateAccessibilityEvent(AccessibilityEvent) on each child. Override this method if custom population of the event text content is required.


在该方法中,您可以按以下方式向事件添加任何文本:

public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
event.getText().add("Hey look!");
return true;
}

关于android - 在辅助功能模式下,我想覆盖 TextView 的 TalkBack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7264037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com