简体   繁体   English

Android辅助功能:一次即可发送多个辅助功能事件

[英]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 ) 我正在为该应用程序添加可访问性,并且我希望它能够使用户触摸图片时能够读取图像和复选框的当前状态(如“已选中”或“未选中”,即辅助功能助手读取的内容,不是truefalse

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.

相关问题 Android Talkback 无障碍事件 - Android Talkback accessibility events Android 辅助功能执行触摸操作 - Android Accessibility perform touch action Android 2.3(GB)中的辅助功能服务无法识别辅助功能事件 - Accessibility Events not recognized by Accessibility service in Android 2.3(GB) 如何使用Android中的辅助功能执行触摸 - How to perform touch using the accessibility in android 在无障碍服务中禁用 Android 中的触摸屏 - Disable touch screen in Android in accessibility service Android 4.4.2辅助功能“按触摸浏览”在应用中不起作用 - Android 4.4.2 Accessibility Explore By Touch not working in app Android:自定义视图未在ListView中提供辅助功能事件 - Android: Custom Views not giving accessibility events in a ListView Android TalkBack:是否有侦听器可以捕获所有辅助功能事件? - Android TalkBack: Is there a Listener to catch all Accessibility Events? 适用于android的辅助功能应用程序,可在所有其他应用程序之上运行,并且可以干预并将触摸/点击事件发送到其他应用程序的视图 - Accessibility app for android that runs on top of all other applications and can intervene and send touch/tap events to views of other apps Android Accessibility-Service突然停止触发事件 - android Accessibility-service suddenly stopped triggering events
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM