This is a module base on CustomListview, all function same with CustomListview I call it CustomCardView. Hope this help.
B4X:
For I = 0 To 5
'(the 47%x is cardview width, and the 45%y is the cardview height)
Listview_CV.Add(CreateListItem(47%x, 45%y), 45%y, I)
btn.Text = "Button" & I
Next
B4X:
Sub CreateListItem(Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
Activity.AddView(p, 0, 0, Width, Height)
p.LoadLayout("Custom_Button")
p.RemoveView
Return p
End Sub