Android Question [SOLVED] Is it possible to un-initialise a panel?

RandomCoder

Well-Known Member
Licensed User
Longtime User
I have a panel containing 5 buttons and it would be nice if I could destroy the panel and all of the views contained within so that a sub I already have can initialise it again.

One option I guess would be to initialise the panel every-time I want to display it but I considered this a waste as normally it is already set exactly the way I want and so I just show or hide it using the visible property. I now have a need to change the layout of the panel and the simplest way would be to just destroy it and let my already written sub take care of it.

My work-around at the moment is to use a global variable to flag when to re-initialise the panel, it would be nicer and easier to follow my code if I could destroy the view and all views contained within. Is this possible?

Kind regards,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Thanks for replying @derez, I've already attempted to use panel.RemoveView but that didn't appear to work as it seems that the panel is still returning that is is initialised even though its view was removed? When I next run the sub that should repopulate it, the sub see's it as already being initialised and displays a blank panel with no buttons.

The hole I've started digging is getting deeper! :eek:
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I think something like this should do what you want:

B4X:
Pnl.RemoveAllViews
Pnl.RemoveView
Dim Pnl As Panel

I'm not sure the first two are really necessary, although it may help with garbage collection.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
I think something like this should do what you want:

B4X:
Pnl.RemoveAllViews
Pnl.RemoveView
Dim Pnl As Panel

I'm not sure the first two are really necessary, although it may help with garbage collection.

Cheers @stevel05 looks like re-declaring the panel has done the trick.
 
Upvote 0
Top