[英]Android Accessibility: sending several accessibility events on a single touch
Inside one of my recycle view adapters, I have a layout which displays an image and a checkbox. 在我的一个回收视图适配器中,我有一个显示图像和复选框的布局。
I am adding accessibility to the app, and I want it so that when a user touches a picture, it will get a reading of the image and the current state of the checkbox (as in, "checked" or "unchecked", which is what the accessibility assistant reads, not true
or false
) 我正在为该应用程序添加可访问性,并且我希望它能够使用户触摸图片时能够读取图像和复选框的当前状态(如“已选中”或“未选中”,即辅助功能助手读取的内容,不是true
或false
)
The two separate lines of code which I have used fit my purpose are as follows: 我使用的两行代码符合我的目的,如下所示:
myImageView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
myCheckbox.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
But if I run that call on the click event, the first instruction is cut short and only the second one is heard. 但是,如果我在click事件上运行该调用,则会缩短第一条指令,只听到第二条指令。 So I believe this might not be the way to go. 因此,我相信这可能不是要走的路。 I probably have to use all of the Accessibility classes provided by Android, but I have no clue where to start. 我可能必须使用Android提供的所有Accessibility类,但是我不知道从哪里开始。
What should I do for the voice feedback to read "Image one, checked... Image two, unchecked". 要使语音反馈阅读“图像一,已选中...图像二,未选中”,我该怎么做。
Additional info: I cannot use strings to get the wanted value from the checkbox boolean because the app is multilingual and instead of having to get all the string resources I would rather take advantage of the system. 附加信息:我不能使用字符串从复选框boolean中获取所需的值,因为该应用程序是多语言的,而不是必须获取所有字符串资源,我宁愿利用系统。
Thank you, everyone, for your time. 谢谢大家。
You can combine both items in a linearlayout and/or you can market the "Image one" part as a label for the checkbox. 您可以将两个项目组合成线性布局和/或可以将“ Image one”零件作为复选框的标签进行销售。 Both examples are shown below and taken from the link below them. 这两个示例均显示在下面,并取自它们下面的链接。
<LinearLayout
android:id="@+id/consumedContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="false"
android:orientation="horizontal">
<TextView
android:id="@+id/coffeeLimitLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_weight="1"
android:labelFor="@id/coffeeLimitValue"
android:text="@string/coffee_limit_label"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
https://www.raywenderlich.com/182100/android-accessibility-tutorial-getting-started https://www.raywenderlich.com/182100/android-accessibility-tutorial-getting-started
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.