A AiChan Member Licensed User Longtime User May 15, 2012 #1 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...
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 May 15, 2012 #2 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: May 15, 2012 Upvote 0
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
A AiChan Member Licensed User Longtime User May 15, 2012 #3 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
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?
stefanobusetto Active Member Licensed User Longtime User May 15, 2012 #4 if i find the post i'll give you the link Upvote 0
mc73 Well-Known Member Licensed User Longtime User May 15, 2012 #5 AiChan said: 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? Click to expand... Perhaps using the tag property as already suggested would be equally efficient. Upvote 0
AiChan said: 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? Click to expand... Perhaps using the tag property as already suggested would be equally efficient.
agraham Expert Licensed User Longtime User May 15, 2012 #6 AiChan said: Im wondering why FindViewByID isnt exposed in B4A since its already in Android? Click to expand... A little simplisticly but as Views are created programmatically at runtime, not by XML declarations, they don't have an ID. Upvote 0
AiChan said: Im wondering why FindViewByID isnt exposed in B4A since its already in Android? Click to expand... A little simplisticly but as Views are created programmatically at runtime, not by XML declarations, they don't have an ID.