Bitmap Help

Omar

Member
Licensed User
Longtime User
Hello,

I have been facing an issue when I try to load a bitmap into an ImageView, I am using the following code:

If Val(Rating) >= 8.5 Then
ImageView2 = LoadBitmap(File.DirAssets, "rating45.gif")
Else
ImageView2 = LoadBitmap(File.DirAssets, "rating40.gif")
End If

Sub Val(s As String) As Int
If Not(IsNumber(s)) Then Return 0
Return s
End Sub

I have already added the ImageView2 in through the designer, but all I get is a blank white box.

Will appreciate any help with this. Thank you.
 

klaus

Expert
Licensed User
Longtime User
You should use:
B4X:
If Val(Rating) >= 8.5 Then
ImageView2[COLOR=red].Bitmap[/COLOR] = LoadBitmap(File.DirAssets, "rating45.gif")
Else
ImageView2[COLOR=red].Bitmap[/COLOR] = LoadBitmap(File.DirAssets, "rating40.gif")
End If

ImageView2 is the name of the view.
ImageView2.Bitmap is the parameter.

Best regards.
 
Upvote 0

Omar

Member
Licensed User
Longtime User
Thank you very much Klaus. That was exactly it.



You should use:
B4X:
If Val(Rating) >= 8.5 Then
ImageView2[COLOR=red].Bitmap[/COLOR] = LoadBitmap(File.DirAssets, "rating45.gif")
Else
ImageView2[COLOR=red].Bitmap[/COLOR] = LoadBitmap(File.DirAssets, "rating40.gif")
End If

ImageView2 is the name of the view.
ImageView2.Bitmap is the parameter.

Best regards.
 
Upvote 0
Top