I keep getting this error when I want to load my image inside a listview.
src\b4a\example\main.java:722: error: inconvertible types
_img1.setObject((android.widget.ImageView)(_image.getObject()));
^
required: ImageView
found: Bitmap
1 error
i'm not sure how exactly I could convert a bitmap into an ImageView, if that would solve the problem.
But here is the code I have:
Any help would be appreciated!
src\b4a\example\main.java:722: error: inconvertible types
_img1.setObject((android.widget.ImageView)(_image.getObject()));
^
required: ImageView
found: Bitmap
1 error
i'm not sure how exactly I could convert a bitmap into an ImageView, if that would solve the problem.
But here is the code I have:
B4X:
Dim List1 as CustomListView
List1.Add(CreateListItem("This is a text","This is another text", List1.AsView.Width, 50dip, LoadBitmap(File.DirAssets, "image.png")), 50dip, "")
Sub CreateListItem(Text As String, Text2 As String, Width As Int, Height As Int, Image As Bitmap) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
Dim img1 As ImageView
img1.Initialize("img1")
img1.Gravity = Gravity.FILL
img1 = Image
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, -6dip, 300dip, Height - 4dip) 'view #1
p.AddView(subtitle, 66dip, -2dip, 300dip, Height - 4dip)
Return p
End Sub
Any help would be appreciated!