如何更改双击和长按的Android对讲说明 [英] How to change Android talkback instructions for double tap and long press
问题描述
我有一个带有长按动作处理程序的视图。我使用内容描述来设置当视图获得焦点时对讲会讲话的消息。
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:
双击以激活,双击并长按
Double tap to activate, double tap and hold for long press
我想将此消息更改为
双击以动作1 ,双击并按住动作2
有没有办法?
我查看了 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 发布答案以来,c $ c> 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屋!