I am trying to load an image in to a panel. When a button is pushed, the image appears on the panel, simple enough.
B4X:
Dim bg As BitmapDrawable
bg.Initialize(LoadBitmap(File.DirAssets, "cam0077.jpg"))
bg.Gravity = Gravity.FILL
pnlImages.Background = bg
It compiles fine, but when I run it, I get a directory or file not found error:
java.io.FileNotFoundException: /C:\Users\Shaun\Documents\b4a\interfacestuff\Files/cam0077.jpg: open failed: ENOENT (No such file or directory)
The file is in the correct directory. Any clue why I am getting this errror?
I got it to work. I added an imageView. I was still getting the error loading it into the imageView, so in the designer view I set the image file property of the ImageView to my image.
After doing that the file not found error went away and the image showed.
OK, I got the error again once I wrote code to make the image appear when I clicked the button. I figured out what was wrong. There was something about the file that it did not like. I loaded a different file that had dashes in it, and still got the error. I took the dashes out, and it loaded as I wanted it to.