programmatically get names

Aysic4Bandroid

Member
Licensed User
Longtime User
Hi,
I would like to see the ability to programmatically get the 'name' property of a view in B4A. Reliance on the 'tag' attribute and creating convoluted ways of doing so seems trivial for something which is so useful and necessary.

If i remember the definition from when i did VB6, the tag attribute is for including extra information to a control or in B4A a view. I almost always have something useful in the tag property of a view so trying to get and reference the views 'name' is hard work.

Something similar to the DOM's getElementById(id) would be good i.e.
getViewNameByTag(tag As string)

When creating dynamic views at runtime this would be a real timesaver.


I shift continually between being amazed at the advanced, great, features of B4A (especially when compared to the learning curve in learning Java/eclipse from scratch) and total bewilderment why it omits some real fundamental stuff.

That said, ill stick with and support b4a any day over the for-mentioned IDE - cos i value my sanity and time.

Way to go Erel & B4A
 

Jost aus Soest

Active Member
Licensed User
Longtime User
@Erel:
I would like to read the Name-property, too!

@Aysic4Bandroid:
You know, that you can also store type variables in the Tag-property?
This type could contain the name of the view and even more informations... (Just to mention a workaround.)
 

Aysic4Bandroid

Member
Licensed User
Longtime User
Hi, ost aus Soest,
Your point regarding the use of type is very interesting, i wanted to use a Type in my current app -
i wanted to create a[n]y number of my custom type, dynamically at runtime the structure of the type comprised:
a panel with 4 child views i.e:

panel
spinner1, spinner2, textinput, spinner3

I thought it would be possible to treat the type like an object where the child views inherit from the parent so when i initialize
the parent panel all child views are initialized - but alas not possible. so in my case, there was little benefit in using a type over
creating 5 seperate views/variables.

I think b4a encourages experiment and finding ways of making things work - im sure many good b4A public modules and libraries are
born from this attitude


hi Erel,
In your example which creates 1001 buttons, each button is referenced as 'b' what if i wanted to give each a unique identifier
such as: b & "_" & i - producing, b_1, b_2, b_3, b_4 etc...

Without putting each button into a structure such as a list or an array referencing a button is difficult -
is it right that lists dont necessarily store values in the same order added with Add()??
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I just tried to demonstrate that their is no real Name value associated with any view. If you like you can use a Map or any other structure that you want to map between a string and a view.
is it right that lists dont necessarily store values in the same order added with Add()??
No. The order is preserved. This is also true for Maps.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…