Android Question [Solved]Panel.loadlayout gives error object shoud first be initialized (imageview)

Martincg

Member
Licensed User
Longtime User
I am trying to build a version of sliding panels. I know there are ready-made solutions.
When I try to add a layout to a panel I get the error

java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (ImageView).

This is part of the code
B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
  For i = 0 To slidePan.Length - 1
       slidePan(i).Initialize("slidePan")
     Activity.AddView(slidePan(i),0,0,100%x, 100%y)
 
   slidePan(i).SendToBack
Next
 slidePan(0).LoadLayout("flowsandtemplayout") '<------------- error here

End Sub
[/COLOR]
All the views have been added to Main using the designer Tools|generate Members.
I have tried the examples and if I try to add my own layout I get the same error, and I have tried different layouts. The layouts work fine in the projects from which they were copied.
What am I doing wrong?

EDIT: There was a png file missing in the Files folder. Since the file was used in the designer for an imageview I am surprised the compiler didn't complain first. I suppose it's part of learning because it hadn't occurred to me that not finding an image was a reason for an imageview not being initialized.

 
Last edited:

Martincg

Member
Licensed User
Longtime User
I have only just noticed that the debugger giving an earlier message which I hadn't noticed giving the name of the problem image. The image name had a space in it, so I renamed the file,loaded the file and removed the old file, changed the image for the imageview and then it ran without errors so I assume spaces in some file names are a bad thing.
 
Upvote 0
Top