Android Question Confused about initialization

HARRY

Active Member
Licensed User
Longtime User
Hi,

I meet strange things I never met before.

In my program all views are defined using the designer.

When I run the program in Debug mode from the PC all goes fine.

When I start that program on the Phone I get a message that various views should first be instialized.

When I run that program in Release mode from the PC all goes fine.

When I start that program on the Phone I get a message that various views should first be instialized.

Those error messages are given on a statement to set the (text) color of e.g. a EditText.

When I add initialization in the source, B4A protests, saying that initialization is already done as the views are added via the Designer.

May be wrongly, but I have used Generate Members for all views.

It is the first time I use Scripting in the Designer, as follows:
'All variants script
AutoScaleRate(0.3)
AutoScaleAll

What did I do wrongly?

Harry
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
When using designer layouts, one must keep in mind that, a view that doesn't need any code interaction, may be used without any further declaration, like labels, that we set once in the designer and don't change within our code, BUT, if views properties are to access in code, then the view must be declared, (dim x as label). Initialisation is not required for designer added views.
 
Upvote 0

HARRY

Active Member
Licensed User
Longtime User
The problem is solved, by moving all code in Activity_Create which I had put under If FirstTime outside that If. Apparently I did not understand when FirstTime is true. After carefully reading the information about Lifecycle in the guide, I think that it works as follows:
The (only) Activity is ended with Activity.Finish.
The OS may keep the process alive for some time.
If I restart the app when the process is still alive, FirstTime is false.

Am I correct?

Harry
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
If I restart the app when the process is still alive, FirstTime is false.

Am I correct?
yes.

Load your layout not only when FirtTime is true
 
Upvote 0
Top