basic4android

Trying to set background image for panel


I am trying to set the background image of a panel that is added in the designer called PanelMaintenance but when the user enters the activity, the panel is not showing up with the image background. There are also no error messages and I was able use this image for the background of a tab host view. Can you check the code and let me know what additional code I'm missing?

'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim PanelMaintenance As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

    PanelMaintenance.Initialize("")
    PanelMaintenance.SetBackgroundImage(LoadBitmap(File.DirAssets, "mybackground.jpg"))
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Update 15-Nov-2011 at 13:39 Added an Activity.LoadLayout statement.

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("Maintenance")
    PanelMaintenance.SetBackgroundImage(LoadBitmap(File.DirAssets, "mybackground.jpg"))
End Sub

Looks like any time a new activity is started it needs the LoadLayout statement in it which will show the panel and all of the views placed on the panel.

So I will call this one answered.


Solution

  • You are missing PanelMaintenance.invalidate.