Android Question Layout Unload Problem

Sreenadh OG

Member
Licensed User
Longtime User
Hai all,
I have a program with three layout, Main page contain three button. I want to unload each layout at particular Button_click, My code given below

Sub button2_click
Activity.LoadLayout ("layout2")
End Sub

Sub button1_click
(code to unload layout3 here???)
(code to unload layout2 here???)
Activity.LoadLayout ("layout1")

End Sub
Sub button3_click
(code to unload layout2 here???)
(code to unload layout1 here???)

Activity.LoadLayout ("layout3")
End Sub
 

Sreenadh OG

Member
Licensed User
Longtime User
But, I have HorizontalScrollView with many Button, after the use of Activity.RemoveAllViews i got following problem

This is my code for main Layout:
B4X:
Activity.LoadLayout("Main") 
itemSize = HsvMain.Width / 3
    HsvMain.Panel.Width = itemSize * 7
        Table = HsvMain.Panel
        Dim p As Panel
        p.Initialize("")
        p.Color = Rnd(0x90000000, -1)
        BtnHome.RemoveView
        BtnListing.RemoveView
        BtnConfig.RemoveView
        BtnAddBk.RemoveView
        BtnSearch.RemoveView
        BtnProfile.RemoveView
        BtnLogut.RemoveView
        BmpHome.Initialize(File.DirAssets,"Home.png")
        BtnHome.SetBackgroundImage(BmpHome) 
        HsvMain.Panel.AddView(BtnHome, itemSize*0, 0, itemSize, HsvMain.Panel.Height)
        HsvMain.Panel.AddView(BtnListing, itemSize*1, 0, itemSize, HsvMain.Panel.Height)
        HsvMain.Panel.AddView(BtnConfig, itemSize*2, 0, itemSize, HsvMain.Panel.Height)
        HsvMain.Panel.AddView(BtnAddBk, itemSize*3, 0, itemSize, HsvMain.Panel.Height)
        HsvMain.Panel.AddView(BtnSearch, itemSize*4, 0, itemSize, HsvMain.Panel.Height)
        HsvMain.Panel.AddView(BtnProfile, itemSize*5, 0, itemSize, HsvMain.Panel.Height)       
        HsvMain.Panel.AddView(BtnLogut, itemSize*6, 0, itemSize, HsvMain.Panel.Height)


B4X:
'Load Next Layout
Sub btnSearch_click
Activity.LoadLayout ("Search")
'This Layout contain many views
End Sub
img.JPG




B4X:
'Now i want to load Main layout again
Sub BtnMain_click
Activity.RemoveAllViews
Activity.LoadLayout("Main")
End Sub

Now i am getting Design problem like this..
imgnew.JPG
 
Upvote 0

Sreenadh OG

Member
Licensed User
Longtime User
Thank u, I solved the problem with Panel...My code is..
B4X:
panel1.Initialize("")
panel1.LoadLayout("Main")
Activity.AddView(panel1, 0, 0, 100%x, 100%y)
Initialize
 
Upvote 0
Top