如何防止android对讲说话的seekbar进度

编程入门 行业动态 更新时间:2024-10-24 22:22:40
本文介绍了如何防止android对讲说话的seekbar进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个自定义控件,扩展了 SeekBar ,在其中覆盖了 onInitializeAccessibilityNodeInfo ,如下所示:

I have a custom control extending SeekBar, in which I have overridden onInitializeAccessibilityNodeInfo as below:

@Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); info.setClassName(TextView.class.getName()); }

然后,我将内容描述设置为此控件的我的控件",但是当可访问性成为该控件的焦点时,对讲仍会说我的控件,%x%".我不希望它说出进度,即"x%".与其说我想覆盖对讲文本,不如说"x percent ...",而是宣布我设置的自定义文本,例如选择了x值".怎么做?

Then I set content description as "my control" to this control, but when accessibility focus comes to this control, talkback still speak "my control, %x percent". I don't want it to speak progress i.e. "x percent". Instead of that I want to override the talkback text so that instead of it announcing "x percent..." it announces custom text that I set e.g. "x value selected". How to do it?

推荐答案

我在C#中的Xamarin.Android中做了类似的事情,但是代码应该足够容易移植回Java.另外,请记住,当控件突出显示时,这些更改将覆盖初始对讲.

I did something similar in Xamarin.Android in C#, but the code should be easy enough to port back to Java. Also, keep in mind these changes will override the initial talkback when the control is highlighted.

首先在textView上跟踪值集:

First on the textView that is keeping track of the value set:

textView.AccessibilityLiveRegion = AndroidViews.AccessibilityLiveRegion.Assertive;

然后我必须创建自己的自定义 AccessibilityDelegate :

Then I had to create my own custom AccessibilityDelegate :

public class CustomSeekbarDelegate : Android.Views.View.AccessibilityDelegate { public override void OnInitializeAccessibilityEvent(AndroidViews.View host, AccessibilityEvent e) { //NOTE: Don't call base to prevent seekbar talkback percentage } } seekBar.SetAccessibilityDelegate(new CustomSeekbarDelegate());

首次突出显示时,可能有一种方法可以同时保留初始语音控件的可访问性,但是在线上并没有太多内容,这足以满足我们的需求.另外,我没有更多的时间尝试使它正常工作.

There's probably a way to keep both the initial spoken control accessibility when first highlighted, but there's not much online about it and this was good enough for our needs. Plus, I didn't have additional time to try and get that working as well.

更多推荐

如何防止android对讲说话的seekbar进度

本文发布于:2023-10-08 02:47:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471285.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进度   如何防止   说话   android   seekbar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!