Android Question View.Parent read-only

LucaMs

Expert
Licensed User
Longtime User
Mainly a "wish".

View.Parent is read-only; can Anywhere Software set it as writable too?

I'm "searching" "the" best way to share B4XViews between B4XPages. The ideal (just one line) would be:
B4X:
' my second B4XPage
B4XPages.MainPage.MyView.Parent = Root
 

LucaMs

Expert
Licensed User
Longtime User
You are posting this wish in the wrong forum.
I know:
Mainly a "wish".


You can not change a Parent of a View.
I know this too and the reason is because Parent is read-only.

modViewsUtils - code module:
B4X:
Public Sub MoveB4XView(xView As B4XView, Destination As B4XView)
    xView.RemoveViewFromParent
    Destination.AddView(xView, xView.Left, xView.Top, xView.Width, xView.Height)
End Sub

B4X:
Public Sub MoveB4XView2(xView As B4XView, Destination As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
    xView.RemoveViewFromParent
    Destination.AddView(xView, Left, Top, Width, Height)
End Sub
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
But those routines aren't ideal, though.

Example:
MyPage2
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("layTwo")
    modViewsUtils.MoveB4XView(B4XPages.MainPage.pnlBottom, Root)
End Sub

If then I need to move pnlBottom to MyPage3 I need to know that it is now in MyPag2.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…