Not sure what i'm doing wrong here

Smee

Well-Known Member
Licensed User
Longtime User
Can any one tell me what is wrong with this code snippet. When i run it i only get a blank screen. But the menu items are available



B4X:
Sub Activity_Create(FirstTime As Boolean)

   Dim kbPanel As Panel
   Dim svOrders As ScrollView
   svOrders.Initialize(180)
   kbPanel.Initialize("")
      
   Activity.AddView(kbPanel,100%x, 0,100%x,100%y)
   kbPanel.LoadLayout("scr3")

   Activity.AddView(svOrders,0,330,400,180)
   
   Activity.AddMenuItem("Customers", "mnuCustomers")
   Activity.AddMenuItem("Catalogues", "mnuCatalogues")
   Activity.AddMenuItem("TempPics", "mnuPicsTemp")

   
End Sub
 

Smee

Well-Known Member
Licensed User
Longtime User
Thanks for the prompt reply David,

I have looked at other code and have not seen that statement for the panels

Should it read like this where i load the layout


Sub Activity_Create(FirstTime As Boolean)

kbPanel.LoadLayout("scr3")
Activity.LoadLayout("scr3")

End Sub
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thank you,

The panel now shows but not the scrollView.

I still don't understand why i am loading Activity.LoadLayout("scr3") after loading the panel. Can you post a pointer where i could read something that explains this

Thanks again

Joe
 
Upvote 0

derez

Expert
Licensed User
Longtime User
The activity must have a layout and it should be loaded, but as you add all your views by code, the layout may be the minimal content - just the activity. It doesn't make sense to load the same layout for both activity and panel.
give tha activity layout another name.
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
You do not need to load a layout to the activity if you add your views via code, so remove that line.

Your problem lies in Activity.Addview, As the first 100%x is Setting the panel to be off the screen, change it to 0 and it should be visible
 
Last edited:
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
Thanks Kicka,

I tried that and it does not show, However it IS there. I know it is because when i hold the tablet at a certain angle i can see the outline or a shadow of the panel in that position.

What am i missing?:confused:
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Your code should look like this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
 Dim kbPanel As Panel
 Dim svOrders As ScrollView
 svOrders.Initialize(180)
 kbPanel.Initialize("")
 
 kbPanel = svOrders.Panel
 kbPanel.LoadLayout("scr3")
 Activity.AddView(svOrders,0,330,400,180)
 
 Activity.AddMenuItem("Customers", "mnuCustomers")
 Activity.AddMenuItem("Catalogues", "mnuCatalogues")
 Activity.AddMenuItem("TempPics", "mnuPicsTemp")
End Sub

or

B4X:
Sub Activity_Create(FirstTime As Boolean)
 Dim svOrders As ScrollView
 svOrders.Initialize(180)
 
 svOrders.Panel.LoadLayout("scr3")
 Activity.AddView(svOrders,0,330,400,180)
 
 Activity.AddMenuItem("Customers", "mnuCustomers")
 Activity.AddMenuItem("Catalogues", "mnuCatalogues")
 Activity.AddMenuItem("TempPics", "mnuPicsTemp")
End Sub
The layout must be set to the internal panel of the ScrollView.
You must perhaps adjust the height of the internal panel to the height of the layout. With svOrders.Panel.Height = xxx.
Or if it is allready defined with svOrders.Initialize(xxx).

Best regards.
 
Upvote 0
Top