如何更改双击和长按的 Android 对讲说明 [英] How to change Android talkback instructions for double tap and long press

查看:20
本文介绍了如何更改双击和长按的 Android 对讲说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有长按动作处理程序的视图.我使用内容描述来设置当视图获得焦点时 Talkback 说话的消息.

I have a view that has a long press action handler. I use the content description to set the message Talkback speaks when the view gets focus.

目前它在获得焦点后立即显示我的内容描述,并在短暂的停顿后说:

Currently it says my content description right after getting a focus, and after a short pause says:

双击激活,双击并长按

我想将此消息更改为类似的内容

I want to change this message into something like

双击action 1",双击并按住action 2"

有没有办法做到这一点?

Is there a way to do so?

我查看了 onPopulateAccessibilityEvent(),它获取了 TYPE_VIEW_ACCESSIBILITY_FOCUSED 事件,但我无法更改所需的消息.

I looked into onPopulateAccessibilityEvent(), it gets TYPE_VIEW_ACCESSIBILITY_FOCUSED event, but I wasn't able to change the desired message.

我是否遗漏了一些简单的东西?

Am I missing something simple?

推荐答案

alanv 发布他的回答后,AccessibilityAction 似乎略有变化.这是一个使用 ViewCompat 的可行解决方案:

It seems AccessibilityAction has changed slightly since alanv posted his answer. Here is a working solution using ViewCompat:

ViewCompat.setAccessibilityDelegate(view, new AccessibilityDelegateCompat() {
    @Override
    public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
        super.onInitializeAccessibilityNodeInfo(host, info);
        // A custom action description. For example, you could use "pause"
        // to have TalkBack speak "double-tap to pause."
        CharSequence description = host.getResources().getText(R.string.my_click_desc);
        AccessibilityActionCompat customClick = new AccessibilityActionCompat(
                    AccessibilityNodeInfoCompat.ACTION_CLICK, description);
        info.addAction(customClick);
    }
});

这篇关于如何更改双击和长按的 Android 对讲说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆