I'm trying to convert a B4A code of CustomListView to work with B4J. I need help please how to convert this code
And then use it with:
B4X:
Sub CreateListItem(Text As String, Text2 As String, Width As Int, Height As Int, Image As Bitmap) As Panel
Dim p as Panel
Dim mycheckboxes as List
Dim chk as Checkbox
p.Initialize("")
p.Color = Colors.Black
Dim img1 As ImageView
img1.Initialize("img1")
img1.Gravity = Gravity.FILL
img1.Bitmap = Image
chk.Initialize("chk")
mycheckboxes.Add(chk)
Dim title as Label
title.Initialize("")
title.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
title.Text = Text
title.TextSize = 16
title.TextColor = Colors.White
Dim subtitle As Label
subtitle.Initialize("")
subtitle.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.BOTTOM)
subtitle.Text = Text2
subtitle.TextSize = 14
subtitle.TextColor = Colors.White
p.AddView(img1, 2dip, 2dip, 50dip, Height - 4dip) 'view #0
p.AddView(title, 65dip, -7dip, 300dip, Height - 4dip) 'view #1
p.AddView(subtitle, 66dip, -2dip, 300dip,Height - 4dip) 'view #1
p.AddView(chk, 88%x, 2dip, 50dip, Height - 4dip) 'view #2
Return p
End Sub
And then use it with:
B4X:
Dim clv as CustomListView
clv.Add(CreateListItem("Title","Subtitle", clv.AsView.Width, 50dip, LoadBitmap(File.DirAssets, "image.png")), 50dip, "")