Android Question Panel reports that it is an Activity using 'Is'

skaliwag

Member
Licensed User
Longtime User
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim p As Panel
    Dim b As Button
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    b.Initialize("")
    p.Initialize("")
    CheckType(p,"p")
    CheckType(b,"b")
End Sub
 
 
Sub CheckType(o As Object,s As String)
    If o Is Panel Then Log(s & " is panel")
    If o Is Button Then Log(s & " is button")
    If o Is Activity Then Log(s & " is activity")
End Sub
The log produced by this is

p is panel
p is activity
b is button

The question is why is the Panel being reported as an Activity?
Thank you.
 

jfranz

Member
Licensed User
Longtime User
So Erel are you saying that a panel is a subtype of Activity? Can you offer any insight into how to tell the difference in code between a Panel and an Activity? Can't really count on checking with Is Activity to determine the base Activity panel.

For example, I am trying to find the top most Activity based on the nested Panels/Views to create a new panel on the top most Activity. I'm currently using the Tag of the activity to allow me to find the Activity. I'm working backwards from a known view and recursively getting a views parent until the Tag matches a known value. This is a kludge at best but does work for me. For a generic custom view this requires every base activity to have the exact same Tag which isn't really the best design.

I would have asked this in another thread but I believe it relates directly to the original question.
 
Upvote 0
Top