Views naming

psevet

Member
Licensed User
Longtime User
Erel,

I don't know if this has been asked previously, but as a newbie I have been struggling for a silly thing : I had a dupplicate view name (edittext1) that was automatically created in 2 pages of a tabhost, the first one being used in my code. Seems like basic4android assumes that the code applied to the last editview created.

My question is, would it be possible that basic4android automaticcally increments view names after checking all existing view names (or at least, names of the same kind of views) ? In my example, since editview1 was allready added in page 1 of my tabhost, the first one that would be added should be edittext2 in page2.

If not, I will get rid of my bad programming habit (forgetting to name views as I add them ...) :sign0104:

Thanks in advance for your assistance.

Pierre
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The problem is that each layout file is completely independent on other files. You can just copy the file to your project and use it.
This decoupling has many advantages as there is no need to maintain all kinds of complex states.
Maybe in the future it will possible to add a "prefix mark" to each layout which will be added automatically to all names.
 

klaus

Expert
Licensed User
Longtime User
I would suggest you to forget the default view names given by the IDE, and as soon as you add a view give it another name beginning with a 3 character prefix indicating the view type and then adding a meaninful name.
Examples.
lblTitle Label for the titel
edtName EditText to enter the name
edtFirstName EditText to enter the firstname
edtAdress EditText to enter the adress
btnLoad Button to load a file
btnSave Button to save a file

I doesn't take so much time as soon as it becomes a habit.
The time 'lost' during the design of the user interface is gained during programing, you don't need to try to remember what EditText1, EditText2 or EditText3 is supposed to do.

Best regards.
 

psevet

Member
Licensed User
Longtime User
Thanks for your advices.

My previous post confirms that I'm lazy (and somewhat absentminded ...)

Cheers.

Pierre
 
Top