advansis Active Member Licensed User Longtime User Jul 26, 2019 #1 Hi guys, I have a problem while checking the type of a view (don't know if previous versions of B4A are affected, mine is 9.30). Code: Copy Dim T As EditText T.Initialize("TXT") T.Text="My Text Value" Activity.AddView(T,10,10,100,100) If T Is Label Then Log("IS A LABEL") End If The EditText object is recognized as a Label (the LOG says: IS A LABEL) ! It is a problem when using GetAllViewsRecursive in a panel populated at runtime.... Is it a bug or inheritance ? If it is inheritance, please tell me how to replicate this feature, sounds interesting... OR ELSE: is there any other way for type-checking ? Thank you
Hi guys, I have a problem while checking the type of a view (don't know if previous versions of B4A are affected, mine is 9.30). Code: Copy Dim T As EditText T.Initialize("TXT") T.Text="My Text Value" Activity.AddView(T,10,10,100,100) If T Is Label Then Log("IS A LABEL") End If The EditText object is recognized as a Label (the LOG says: IS A LABEL) ! It is a problem when using GetAllViewsRecursive in a panel populated at runtime.... Is it a bug or inheritance ? If it is inheritance, please tell me how to replicate this feature, sounds interesting... OR ELSE: is there any other way for type-checking ? Thank you
agraham Expert Licensed User Longtime User Jul 26, 2019 #2 advansis said: Is it a bug or inheritance Click to expand... Inheritance! Check for type 'EditText' before checking for 'Label'. EditText and Label will both look like a 'View' as well Upvote 0
advansis said: Is it a bug or inheritance Click to expand... Inheritance! Check for type 'EditText' before checking for 'Label'. EditText and Label will both look like a 'View' as well
ALBRECHT Active Member Licensed User Jul 27, 2019 #3 Ok, so with IS instead of GetType, no way to use the Select case statement ... to check the Type of Object ? Upvote 0
Ok, so with IS instead of GetType, no way to use the Select case statement ... to check the Type of Object ?
agraham Expert Licensed User Longtime User Jul 27, 2019 #4 ALBRECHT said: no way to use the Select case statement Click to expand... I don't know, I've never tried. When I need to check a type I use If ... Else If ... End If Upvote 0
ALBRECHT said: no way to use the Select case statement Click to expand... I don't know, I've never tried. When I need to check a type I use If ... Else If ... End If
klaus Expert Licensed User Longtime User Jul 27, 2019 #6 ALBRECHT said: no way to use the Select case statement ... Click to expand... Sure you can! Code: Copy Sub WhichObject(Obj As Object) Select True Case Obj Is EditText Log("EditText") Case Obj Is Button Log("Button") Case Obj Is Label Log("Label") Case Obj Is ListView Log("ListView") End Select End Sub Last edited: Jul 27, 2019 Upvote 0
ALBRECHT said: no way to use the Select case statement ... Click to expand... Sure you can! Code: Copy Sub WhichObject(Obj As Object) Select True Case Obj Is EditText Log("EditText") Case Obj Is Button Log("Button") Case Obj Is Label Log("Label") Case Obj Is ListView Log("ListView") End Select End Sub
ALBRECHT Active Member Licensed User Jul 27, 2019 #7 - perfect, it's better for me. - in this case also, it s necessary to check the Label at the end, as said Agraham above ? Upvote 0
- perfect, it's better for me. - in this case also, it s necessary to check the Label at the end, as said Agraham above ?
klaus Expert Licensed User Longtime User Jul 27, 2019 #8 ALBRECHT said: it s necessary to check the Label at the end, as said Agraham above ? Click to expand... Yes! Upvote 0
ALBRECHT said: it s necessary to check the Label at the end, as said Agraham above ? Click to expand... Yes!