Get view by id?

AiChan

Member
Licensed User
Longtime User
Im new to B4A, but have experience with programming in Java for Android. And i was wondering if its possible to reference a view by ID? In Android you have 'findViewByID'. In B4A i can only get a view by Index, which is kinda useless, because when do you know the exact id?

I want to make a gallery. Download image with HttpUtils. Then when a image is done downloading, i would like to get the ImageView by ID (that would be the imagename) and then set the image.

The only way i can think of is making a Map where the Key is the imagefilename (this i can get from the url in JobDone event), and value the reference to the ImageView. Is this the way to go? Seems a bit sideways...
 

stefanobusetto

Active Member
Licensed User
Longtime User
i remember i've read a post on the matter
if i'm not worg there is no way to get the id of a view
anyway you can use the tag property to store any kind of reference
 
Last edited:
Upvote 0

AiChan

Member
Licensed User
Longtime User
Ah ok :) So i could iterate over all views and return if it matches my search string. Not the best sollution but it would work.

Im wondering why FindViewByID isnt exposed in B4A since its already in Android?
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Ah ok :) So i could iterate over all views and return if it matches my search string. Not the best sollution but it would work.

Im wondering why FindViewByID isnt exposed in B4A since its already in Android?

Perhaps using the tag property as already suggested would be equally efficient.
 
Upvote 0
Top