Android Question Getting file name of image loaded in an ImageView

Status
Not open for further replies.

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I would like to get the file name of the image that's loaded in an ImageView.

I have tried this but the coding is not correct.

Can you show me the correct syntax to do it?

It tells me "Types do not match"

Thanks.

B4X:
If ImageViewQuarterPastChimes.Bitmap = "light-on-icon.png" Then
    ' Do something.
Else
    ' Do something else.
End If
 

zcc

New Member
You can set the image file name by:
B4X:
ImageViewQuarterPastChimes.Bitmap =  = LoadBitmap (File.DirAssets, "light-on-icon.png")
Make sure you add the new file to the project from: Windows Menu ---> File Manager
 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
You can set the image file name by:
B4X:
[CODE=b4x]ImageViewQuarterPastChimes.Tag =  "light-on-icon.png"
B4X:
ImageViewQuarterPastChimes.tag =  "light-on-icon.png"
[/CODE]
Make sure you add the new file to the project from: Windows Menu ---> File Manager
However once the file is loaded, as Erel says there is no way to get the filename from the imageview directly unless you add something like:

B4X:
ImageViewQuarterPastChimes.tag = "light-on-icon.png"

then later you can do

B4X:
private filename as string = ImageViewQuarterPastChimes.tag
'or as in the example from post 1
If (ImageViewQuarterPastChimes.tag.as(string).compareto("light-on-icon.png") = 0) Then
    ' Do something.
Else
    ' Do something else.
End If
edited to use example from post 1
 
  • Like
Reactions: zcc
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Got me .. thought Erel had just replied and gave him a Like ... :)
 
  • Like
Reactions: zcc
Upvote 0
Status
Not open for further replies.
Top