Android Question How to bitmap for "AddTwoLinesAndBitmap2"

Yayou49

Active Member
Licensed User
Hy !

On a layout, I have 1 button (BT) with one bitmap drawable (.png file).

On a list (Lst), with AddTwoLinesAndBitmap2, I would like to add an icon according to icon of button (BT).

I've tried something like this:

B4X:
Dim Image As Bitmap
Image = Bt.Background
Lst.AddTwoLinesAndBitmap2("Text1","Text2",Image,1)
Unfortunately, it doesn't work ....
I've got the error:
"incompatible types: Drawable cannot be converted to Bitmap"
I've tried to declare image as BitmapDrawable but still again :
"incompatible types: BitmapDrawable cannot be converted to Bitmap"
I think Bt.Background cannot be use as I think ....
But, how to get an image not directly stored on the device but coming from the layout ?

Any suggestions ???
Thanks in advance.
 

klaus

Expert
Licensed User
Try this:
B4X:
Dim Image As BitmapDrawable
Image = Bt.Background
Lst.AddTwoLinesAndBitmap2("Text1", "Text2", Image.Bitmap, 1)
Not tested.
 

Yayou49

Active Member
Licensed User
Idea was good, but ....
CastException: android.graphics.drawable.StateListDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
Anyway, I found another trick to do what I need :)
Neverless,thanks for your answer.

Instead of an object button, I took an object Image (Im) and then:
B4X:
Dim Image As Bitmap
Image = Im.Bitmap
Lst.AddTwoLinesAndBitmap2("Text1","Text2",Image,1)
It works fine !!!! :cool:
 
Top