Android Question Create panel with no parent

joneden

Active Member
Licensed User
Longtime User
Hi All,

Apologies if already asked (I'm sure it must have been).

Is there any way to create a panel that is an orphan without a parent. I want to be able to create one and assign a height and width to it BEFORE it is used. The code below blocks me because the panel needs a parent...

B4X:
Dim uxPanel As Panel : uxPanel.Initialize("uxPanel")
uxPanel.Width = 85%x
uxPanel.Height = 50dip

Kind of complicated reasoning but I am simplifying my code and if I can create a panel & it's content then I can just pass that to the routine that does the custom dialog box. Otherwise I need to create the dialog box object before the panel and then the code gets messy again... Complicated like I said :(

Regards

Jon
 

joneden

Active Member
Licensed User
Longtime User
Thanks Jon,

I have to say that I didn't expect that to work as there is no proper way of transferring a view from one parent to another. I had thought that using the RemoveViewAt function would destroy the view being removed but this didn't so it allowed a type of transfer from one parent to another. Great stuff!
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
To move a view from a parent to another, you have to use the "removeview" method to remove it from its actual parent and then use the parent "addview" to give it its new parent. The view's size is/must be specified on each "addview"
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Yeah that what I found - I had thought that when removing the view it got destroyed but was happy to see (in this case) that it doesn't. :)
 
Upvote 0
Top