Hi guys,
I have a codes from this forum to get a relative position on any views.
With Default Project, this codes worked OK, but not with Project based on B4XPages.
The error occured on B4x Main Page, with these codes
If that codes change to this
When users click Button1, it worked fine.
Any hint how to solve this?
Attached is the sample project with that error.
I have a codes from this forum to get a relative position on any views.
With Default Project, this codes worked OK, but not with Project based on B4XPages.
The error occured on B4x Main Page, with these codes
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Log(GetRelativeLeft(Panel1)) 'this caused the error'
End Sub
Public Sub GetRelativeLeft(V As JavaObject) As Int
If GetType(V) = "android.view.ViewRoot" Or GetType(V) = "android.view.ViewRootImpl" Then
Return 0
Else
Try
Dim VW As View = V
Return VW.Left + GetRelativeLeft(V.RunMethod("getParent",Null))
Catch
Return GetRelativeLeft(V.RunMethod("getParent",Null))
End Try
End If
End Sub
If that codes change to this
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Sub Button1_Click
Log(GetRelativeLeft(Panel1))
xui.MsgboxAsync(GetRelativeLeft(Panel1), "B4X")
End Sub
When users click Button1, it worked fine.
Any hint how to solve this?
Attached is the sample project with that error.