B4J Question ImageView.SetImage sets a new image object?

KMatle

Expert
Licensed User
Longtime User
Today I mentioned that

B4X:
ItemImageIV.SetImage(fx.LoadImage(File.GetFileParent(FileImg), File.GetName(FileImg)))

and

B4X:
Dim img as image
img=fx.LoadImage(File.GetFileParent(FileImg), File.GetName(FileImg))
ItemImageIV.SetImage(img)

is NOT the same.

It seems that in #2 the img object replaces the IV's internal image object, #1 just loads the image into it. I had some trouble because the IV's image was not visible updating in some cases.

I was expecting the method .SetImage() just to load the given image and not the object :D Am I wrong here?
 

derez

Expert
Licensed User
Longtime User
For an ImageView, in GetImage the definition is:

upload_2017-2-21_22-42-13.png


But SetImage is only for Set.

Was it not meant to be .Image (without get or set), one method for both ?
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
I was expecting the method .SetImage() just to load the given image and not the object
I think in both cases setImage loads and object, the difference is that in your second example you can reuse the same image (img) for another purpose. Javafx is well built and can reuse instances of the same object in multiple controls.
 
Upvote 0
Top