Android Question B4XViews base (and events)

LucaMs

Expert
Licensed User
Longtime User
Trying to write an utility routine useful to move a B4XView from a B4XPage to another one, I found... a wall ?

For this routine it would be necessary to obtain the base of the B4XView and also to be able to apply a specified elevation to it (please, do not answer that BringToFront is enough since it isn't).

B4X:
Public Sub MoveViewBwPages(xView As B4XView, DestPageRoot As B4XView, Elevation As Int)
    MoveViewBwPages2(xView, DestPageRoot, xView.Left, xView.Top, xView.Width, xView.Height, Elevation)
End Sub

Public Sub MoveViewBwPages2(xView As B4XView, DestPageRoot As B4XView, Left As Int, Top As Int, Width As Int, Height As Int, Elevation As Int)
    xView.RemoveViewFromParent
    DestPageRoot.AddView(xView, Left, Top, Width, Height)
    ' Here I would set the elevation of the xView's base.
End Sub


Note:
a - luckily I just want to move a full screen panel containing only a B4XLoadingIndicator and this is easy to do (I could also put these two views in each layout but I don't like it)
b - moving views from one page to another can be done but unfortunately it will not be possible to "move" the event routines - I should think of a way to "delegate" them.
 

LucaMs

Expert
Licensed User
Longtime User
Because (serious and less serious answers, as always, from me ):

1 - I thought I would use the advantages of B4XPage to "share" the views (not really sharing, since I removed a view from one page to put it in another)
2 - because I had not taken into account that loading a layout does not mean deleting all the views already present
3 - I must necessarily be able to set the elevation of my panel above all the views already present; but what if the B4XView is not a panel?

Certainly your solution solves the events problem.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I must necessarily be able to set the elevation of my panel above all the views already present; but what if the B4XView is not a panel?
Why do you need to touch the elevation? This is usually not needed. If you are creating a dialog then save yourself hours of work and use B4XDialog.

Two options:
1. Put it in a panel.
2. Set the elevation with JavaObject.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Why do you need to touch the elevation? This is usually not needed. If you are creating a dialog then save yourself hours of work and use B4XDialog.
That's the intent but I thought I might need to do the same thing in different situations, not for a dialog, and so I was looking for a way to get the base of a B4XView (if that's possible).

2. Set the elevation with JavaObject.
This would work with B4A and B4J but B4i?
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
and then how to do so, with the B4XPages, that in all three platforms I can add a B4XView at runtime above the others?
I learnt that we could load another layout over the existing and both shows, somewhere in the Forum.

Regards,

Anand
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
and then how to do so, with the B4XPages, that in all three platforms I can add a B4XView at runtime above the others?
In most cases you don't need to set the elevation. If you do need then do it with the designer or at runtime:
B4X:
#If B4A
Dim p As Panel = SomeView
p.Elevation = 10dip
#end if
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…