iOS Question CustomListView & Bitmap

fishwolf

Well-Known Member
Licensed User
Longtime User
How to i can add a image into a CustomImageView ?

with this code i have this error

-[UIImage superview]: unrecognized selector sent to instance 0x15d61710

B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
Dim Photo As Bitmap
Dim lbl As Label

   p.Initialize("")
   p.Color = Colors.Black

   
   Photo.Initialize(File.DirAssets, "photo.jpg")
   
   lbl.Initialize("lbl")
   lbl.TextAlignment = lbl.ALIGNMENT_LEFT
   lbl.Text = Text
   lbl.TextColor = Colors.White
   lbl.Font = Font.CreateNew(16)
   
   p.AddView(lbl,  155dip, 2dip, 150dip, Height - 4dip) 'view #0
   p.AddView(Photo,  0, 2dip, 50dip,  Height + 120dip) 'view #2
   
   Return p
   
End Sub
 

tamayo461

Member
Licensed User
Longtime User
this works from me...

Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
Dim b As Bitmap
b.Initialize(File.DirAssets,Text&".png")
Dim i As ImageView
i.Initialize("")
i.Bitmap = b
Dim lbl As Label
lbl.Initialize("lbl")
lbl.TextAlignment = lbl.ALIGNMENT_CENTER
lbl.Text = Text
lbl.Font = Font.CreateNew(16)
lbl.TextColor = Colors.White
p.AddView(i, 0,0,Height,Height)
p.AddView(lbl, Height+5dip,0,Width/3,Height)

Return p
End Sub
 
Upvote 0
Top