Android Question How can I LoadBitmap from File.DirAssets... using customlist view

Hedgar

Member
Hi Guys. I'm stuck trying to use my own icons on a customlistview. I tried fontawsome icons but they are not to my liking. i know the code for listviews is

ListView1.AddTwoLinesAndBitmap2("Results", "", LoadBitmap(File.DirAssets, "report_card_96px.png"),0):

but i can't get for customlistview. Kindly assist.
Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Loading bitmaps:
B4X:
Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets, "image file") 'actually better to use LoadBitmapResize
2. Create a layout file with ImageView and any other views you like.
3:
B4X:
Sub Globals
    Private clv1 As CustomListView
    Private xui As XUI
    Private ImageView1 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    Dim bmp As B4XBitmap = xui.LoadBitmap(File.DirAssets, "image file")
    clv1.Add(CreateListItem(bmp, 100%x, 60dip), Null)
End Sub

Sub CreateListItem(Image As B4XBitmap, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("CellItem")
    ImageView1.SetBitmap(Image)
    Return p
End Sub
 
Upvote 0
Top