BUG: "Is Label" does not work

Informatix

Expert
Licensed User
Longtime User
Example (add a panel and fill it with many different views including labels) :

B4X:
Sub LogLabelText(pnl as Panel)
   For i = 0 To pnl.NumberOfViews - 1
      Log(pnl.GetView(i))
      If pnl.GetView(i) Is Label Then
         Dim lbl As Label
         lbl = pnl.GetView(i)
         Log("TEXT=" & lbl.Text)
      End If
   Next
End Sub

Checkbox and EditText are considered as labels.
 

Roger Garstang

Well-Known Member
Licensed User
Longtime User
I had a hard time finding the threads when needing them too. Might be good to make it a sticky and/or in the documentation. The main threads I found show a test order like:

B4X:
If Activity.GetView(i) Is Button Then
       Log(i & " Button")
Else If Activity.GetView(i) Is EditText Then
       Log(i & " EditText")
Else If Activity.GetView(i) Is Label Then
     Log(i & " Label")
End If

It comes down to the Class Label is in Java is like a Parent class the others derive from, so you need to test for them first since a Button and Edit view are a Label. You have the same thing in Windows development with things like a Checkbox and a Radio/Option Button both being a Button, etc.
 
Top