Android Question GetAllViewsRecursive and "Is" a type of View

sirjo66

Well-Known Member
Licensed User
Longtime User
Hello to all,

I have a problem with GetAllViewsRecursive :(

I need to do some action on my views on a layout, and I use this code:
B4X:
For Each v As View In Activity.GetAllViewsRecursive
   If v Is Button Then
     Dim b As Button = v
     ' ........ execute some actions on button
     ExecBtn(b)
   End If
   If v Is Label Then
     Dim l As Label = v
     ' ........ execute some actions on label
     ExecLbl(l)
   End If
Next

what's wrong on it ??

I execute the program step by step (debug legacy mode) and:
- if "v" is a Button, it execute ExecBtn and ExecLbl (it's wrong)
(yes it is very strange, If v Is Label is True !!)
- if "v" is a Label, it execute only ExecLbl (it's right)
- if "v" is a EditText, it execute only ExecLbl (it's wrong, no need actions on EditText)
(If v Is Label is True !!)

I don't know why it, and how to solve ??

Thanks
Sergio
 
Top