how to get TEXT field of all the view ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Just to make app translation using AHLocale with Get.Text, i need to make a loop getting all the views, but need to check if TEXT field exists to try to get this text to be translated.

B4X:
Sub GetAllTexts (Activity As Activity)
Dim a As View
For i=0 To Activity.NumberOfViews - 1
      a = Activity.GetView(i)
      If a.text  - 'no TEXT field, as not all views have it
Next
End Sub

"View" type has no TEXT field, how to get it universally from all view types, if exists ?
 

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel !
 
Last edited:
Upvote 0

lymey

Active Member
Licensed User
Longtime User
You can use this code:

B4X:
   For i = 0 To Activity.NumberOfViews - 1
      Dim lbl As Label
      If Activity.GetView(i) Is Label Then
         lbl = Activity.GetView(i)
         Log(lbl.Text)
      End If
   Next

All EditTexts are actually a special type of labels (EditText is a subclass of TextView, and Label is actually a TextView).
Is it possible to set the view text also?
I would like to scan through the views in an activity and then set/reset the text value of a view depending on the text or tag value.
 
Upvote 0
Top