Android Question free panel.loadlayout

hub73

Active Member
Licensed User
Longtime User
Hi !

I use a spinner and a panel to choose a layout to display.

B4X:
sub spinner_itemclick()

select ...

case "one"
    panel.loadlayout ("one")

case "two"
   panel.loadlayout ("two")

end select

...

end sub

Should i free the previous loaded panel when i load a new .bal ? How to do this ? (clear the previous panel bal below)

Thanks.
 

johndb

Active Member
Licensed User
Longtime User
I would initialize the panel object prior to entering the "select/case" code structure. In that way, you are assured of having a fresh panel.

John
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
panel.initialize ("eventname")
Oh no.
B4X:
Sub Spinner_ItemClick()
    Panel.RemoveAllViews
    Select ...
    Case "one"
       Panel.loadlayout ("one")
    Case "two"
       Panel.loadlayout ("two")
    End Select
    ...
End Sub
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
Why not just reinitialize the panel to remove all the previous views and reset the object?
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
Because you initialize each time a new object, the previous ones remain with their layout !
@klaus Thank you for the clarification. I was under the assumption that if you reinitialized an object using the same variable name it wouldn't create a new object but reset the previous object by releasing all of its children (views).
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…