Android Question Get top-parent (Main)

LucaMs

Expert
Licensed User
Longtime User
Am I wrong or is there no snippet to get the Main from a B4XView?

And, if it isn't there: "Is it possible that I have to do everything in this house?" (Italian saying ? )

It can be useful (at the moment I need it); not only that, I think it should be part of all B4XViews, even the custom ones.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Done but...
B4X:
Sub GetTopParent(XV As B4XView) As Object
    If XV.Parent.IsInitialized = False Or XV.Parent = Null Then
        Return XV
    Else
        Return GetTopParent(XV.Parent)
    End If
End Sub
in B4J (I made the wrong choice, I should have opened this thread in the B4J forum) it returns an AnchorPane, not the Form ?


P.S. It's fine for me anyway; I need to get the width and height of the top container of a B4XView and these two values of the returned AnchorPane should be what I need.

P.P.S. It does not work in B4A ?
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You can get the top container with the code you posted.
P.P.S. It does not work in B4A ?
However, I would have only needed it for B4J (and subsequently I did it differently, I asked for the Form as a parameter).



1704006374588.png
:)
 
Upvote 0
Top