Android Question loading layout in a panel

apty

Active Member
Licensed User
Longtime User
i am having trouble with the below code. The layout is not loaded, i just get a blank screen.

Code: Copy
Dim pnlx As Panel
    pnlx.Initialize("")
    pnlx.LoadLayout("products")
    Activity.AddView(pnlx,0dip,0dip,100%x,100%y)

What could be wrong?
 
this works but what of cases where i need to load layouts in a scrollview like in the example below? The below code also gives me a blank screen.

Code: Copy
Dim btnx As Int=0
    For i=0 To 6
        Dim pnlx As Panel
        Dim lblCategory As Label
        Dim pnlCategoryItems As Panel
        Dim imgCategory As ImageView
        'Dim Panel1 As Panel
        
        pnlx.Initialize("")
        pnlx.LoadLayout("categories")
        
        If i=0 Then
            
            lblCategory.Text="Bc"
            imgCategory.Bitmap=LoadBitmap(File.DirAssets,"bd.png")
            Else if i=1 Then
            lblCategory.Text="Cx"
            imgCategory.Bitmap=LoadBitmap(File.DirAssets,"cx.png")
        End If
        
        ScrollViewMain.Panel.AddView(pnlx, 0,btnx,100%x,290dip)
        
        
        btnx=btnx+290dip
    Next
    ScrollViewMain.panel.Height=btnx
 
Upvote 0
pnlx.Initialize("")
Code: Copy
pnlx.Initialize("")
pnlx.setlayout(.....)

The panelsize must be known. add the panel to the activity and remove it after you loaded the layout. Otherwise you need to define the panels size.
 
Upvote 0
strange enough, the same code works in another project. The below code works but on a different project. i just copied the same code to the current project and it doesn't work.

Code: Copy
Dim btnx As Int=0
    For i = 0 To 5
        Dim panelx As Panel
        Dim lblNames As Label
        Dim lblPass As Label
        Dim lblCost As Label
       
       
       
        panelx.Initialize("")
        panelx.LoadLayout("summary")
        lblNames.Text="test"
       
        lblPass.Text="test"
        lblCost.Text=500

        ScrollView1.Panel.AddView(panelx, 0,btnx,98%x,60dip)
        btnx=btnx+80dip

    Next
   
    ScrollView1.panel.Height=btnx
 
Upvote 0
Back
Top