Wish: Ability to call SetContentDescription() on Android views

Steve

Member
Licensed User
Longtime User
Greetings,

Most native Android widgets provide a method called SetContentDescription() which allows developers to provide info useful to blind/low vision users who rely on Android screen readers like Talkback, Spiel, and Mobile Accessibility. I specifically want to be able to set this field for views like the seekbar control so that blind users of an app I'm working on will be able to more easily determine what they are adjusting when they change the bar's position.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use the reflection library to do it:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim b As Button
   b.Initialize("")
   SetContentDescription(b, "example")
End Sub

Sub SetContentDescription(v As View, Text As String)
   Dim r As Reflector
   r.Target = v
   r.RunMethod2("setContentDescription", Text, "java.lang.CharSequence")
End Sub
 

Steve

Member
Licensed User
Longtime User
Ahah, very cool, and props as always to you for the quick response and Andrew for the reflection lib. The latter especially opens up a lot of possibilities for those of us who are bless/cursed to know Java. :)

Steve

You can use the reflection library to do it:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Dim b As Button
   b.Initialize("")
   SetContentDescription(b, "example")
End Sub

Sub SetContentDescription(v As View, Text As String)
   Dim r As Reflector
   r.Target = v
   r.RunMethod2("setContentDescription", Text, "java.lang.CharSequence")
End Sub
 
Top