Android Question B4X Views Question

Maxcfgos

Member
Licensed User
In the latest version of B4A, when I create a new project, a button that shows a message box appears by default. This button appears in the Layout but is not declared in the variables section (globals or process globals). Do B4X Views not need to be declared?
 
Do B4X Views not need to be declared?

You only need to declare views (Layout views) if you are going to reference them in your code.

For example , change a Labels colour or or set a views visible property to True or False.
 
Upvote 0
By the way ... Welcome to the Forum .

If you have not already done so there is some great reading here ...

 
Upvote 0
This button appears in the Layout but is not declared in the variables section (globals or process globals). Do B4X Views not need to be declared?
You forgot to use

B4A_ETr9Gl06E2.png


On them. The declaration only happens when you use Generate Members. It is nothing automatically.
 
Upvote 0
Views added in the visual designer do not need to be declared for their events to work and do not need to be initialised. They only need to be declared, using the generate members menu, if you are going to access other methods.

If you are adding views by code, then you need to initialize them!
 
Upvote 0
I think he's referring to the default project you get when you select "New/B4XPages" from IDE.
It comes with a layout with a single button that triggers a MsgBox.
Button is not declared because only the event _Click is used.
 
Upvote 0
I think he's referring to the default project you get when you select "New/B4XPages" from IDE.
It comes with a layout with a single button that triggers a MsgBox.
Button is not declared because only the event _Click is used.
yes, I know... and we are trying to explain why it is as it is...
 
Upvote 0
Back
Top