Android Question Showing bitmaps... one works, but the other doesn't

App Dude

Active Member
Licensed User
Longtime User
I've narrowed down my issue to this...

B4X:
Sub Class_Globals
    Private ivLogo As B4XView
    Private ivSettings As B4XView
End Sub

...

Private Sub B4XPage_Created (Root1 As B4XView)
    ...
    Dim b As Bitmap
    Log("ivLogo is initialized = " & ivLogo.IsInitialized)                ' Shows true
    b.Initialize(File.DirAssets, "Logo-C-v03-160x120-3C-BlackBG.bmp")
    ivLogo.SetBitmap(b)
    
    Dim gearBmp As Bitmap
    Log("ivSettings is initialized = " & ivSettings.IsInitialized)        ' Shows false
    gearBmp.Initialize(File.DirAssets, "Gear-Green.bmp")
    ivSettings.SetBitmap(gearBmp)
    ...
End Sub

Both ImageViews are created in the designer. But the first image shows properly, and the other crashes with the dump saying " java.lang.RuntimeException: Object should first be initialized (B4XView). " (on line 18 above).
The Log lines above show the first one, ivLogo, as True, but the second one as False.
Huh?

There is no initialize method for a B4X Image View, so not sure what else I should be doing before this.
Any clues?
Thanks.
 

App Dude

Active Member
Licensed User
Longtime User
Upload a small project showing the problem. Hard to help without seeing your project. The files in Assets must be lowercase though.

Found this issue, while creating the test project... the imageviews are on a panel in a scrollview, and I needed to load the panel into the scrollview first.
It's currently working with the Logo file in mixed case (along with others). I can change to lowercase... was this a thought as the possible issue, or is this a must-do?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…