Android Question No Images shown in customlistview

ViMeAv ICT

Member
Licensed User
Longtime User
I use the following code but get no images in the customlistview.
What am I doing wrong?

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout1")   
    For i = 0 To 10
        MainList.Add(MainItem,"Main Group")
    Next
End Sub

Sub MainItem As B4XView
    Dim p As B4XView = xui.CreatePanel("Panel")
    p.SetLayoutAnimated(0,0,0,MainList.AsView.Width,MainList.AsView.Height/4)
    Dim bmp As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "1.jpg", MainList.AsView.Width,MainList.AsView.Height/4, False)
    p.SetBitmap(bmp)
    ''p.Color = Rnd(0xff000000, 0xffffffff)
    Return p
End Sub
 

zed

Active Member
Licensed User
you have to use p.LoadLayout("layout")

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    
    Private MainList As CustomListView
    Private Label1 As Label
    Private ImageView1 As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    For i = 0 To 10
        MainList.Add(MainItem("legend",i), "")
    Next
End Sub

Sub MainItem(txt As String, n As Int) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0,MainList.AsView.Width,MainList.AsView.Height/4)
    p.LoadLayout("img")
    Label1.Text = txt&" - "&n
    ImageView1.Bitmap = xui.LoadBitmap(File.DirAssets,"1.jpg")
    Return p
End Sub
 

Attachments

  • clv_imv.zip
    27.6 KB · Views: 50
Upvote 0

ViMeAv ICT

Member
Licensed User
Longtime User
Ok, I had seen this before. You need an extra layout. Thanks!
But I have another question, concerning the layout.
How can I arrange the customlist the way it shows 4 pictures at a time, completely filled the customlist.
(even by using pictures with different sizes)
See picture please.
1.jpg
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
How can I arrange the customlist the way it shows 4 pictures at a time
See complete example by Erel
 
Upvote 0
Top