I am implementing "Read Aloud
" or "Talkback
" for an app. Everything is working with contentDescription
text, but with option menu, I found nothing related to contentDescription
, I want system read "Menu "+ item's name
.
EX: My menu has 2 items: "Create New Folder" and "Delete current folder", currently, when I focus a menu item (Support trackball and bluetooth key), system can talk exactly the menu's text. But I want it talks more like "1: Menu Create New Folder" and "2: Menu Delete current folder".
So, How can I change the read text? How can I get the focused menu item
when bluetooth keyboard press UP/DOWN
key?
As my investigation, in Android internal source code, class ActionMenuItemView.java
method setTitle(CharSequence title)
, the source code also sets setContentDescription(title)
, so Android will read your MenuItem's text as default. I don't know why the core has so inflexible in this case.
Updated:
Thanks for @sofakingforever answer.
Seem Google
just added the setContentDescription(CharSequence contentDescription)
method to the MenuItem
class on API 26 (Android O
).
Updated:
Thanks for new @tim.paetz answer .
Look like all versions are now supported setContentDescription
for menu item using android support v4
libraries.