Android Question Error: inconvertible types

Discussion in 'Android Questions' started by trueboss323, Feb 20, 2015.

  1. trueboss323

    trueboss323 Active Member Licensed User

    I keep getting this error when I want to load my image inside a listview.

    src\b4a\example\ error: inconvertible types
    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:
    Dim List1 as CustomListView

    "This is a text","This is another text", List1.AsView.Width, 50dipLoadBitmap(File.DirAssets, "image.png")), 50dip"")

    Sub CreateListItem(Text As String, Text2 As String, Width As Int, Height As Int, Image As BitmapAs Panel
    Dim p As Panel
        p.Color = 
    Dim img1 As ImageView
        img1.Gravity = 
    img1 = 
    Dim title As Label
        title.Gravity = 
    Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        title.Text = Text
        title.TextSize = 
        title.TextColor = 
    Dim subtitle As Label
        subtitle.Gravity = 
    Bit.OR(Gravity.CENTER_VERTICAL, Gravity.BOTTOM)
    subtitle.Text = Text2
        subtitle.TextSize = 
        subtitle.TextColor = 
    2dip2dip50dip, Height - 4dip'view #0

    65dip, -6dip300dip, Height - 4dip'view #1
        p.AddView(subtitle, 66dip, -2dip300dip, Height - 4dip)
    Return p
    End Sub
    Any help would be appreciated!
  2. sorex

    sorex Expert Licensed User

    just pass the image filename and load it in that sub which makes it easier to read the sub line.

    it is probably bouncing on this

    img1 = Image

    img1 is an imageview and not a bitmap, try img1.bitmap=image instead
    DonManfred likes this.
  3. trueboss323

    trueboss323 Active Member Licensed User

    Your method actually worked! Thank you very much.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice