Android Question How to check if a view is an Activity or a Panel

klaus

Expert
Licensed User
Longtime User
I need to know if a view is an Activity or a Panel.
What's the best way to check it ?
If View Is Activity Then is True even if View is a Panel.
and GetType(View) returns the syme type.
both don't work because Activity and Panel seem to be considered beeing the same in B4A?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Merci Fred.
At the moment I use another workaround.
I check the type of the parent view.
B4X:
If GetType(GetParent(v1)) = "android.widget.FrameLayout" Then
    ' Activity
Else
    ' Panel
End If

Private Sub GetParent(v As Object) As Object
    Dim jobj = v As JavaObject
    Return jobj.RunMethod("getParent", Null)
End Sub
But yours looks easier :).
 
Upvote 0
Top