Newcomer question!?

prokli

Active Member
Licensed User
Longtime User
Hi, everybody!

I started with programming android4basic examples a couple days ago and I am fine with most of the examples provided by this forum. But I still haven't found an explanation of what "Initialize" is for. I am a experienced VB programmer since several years but I cannot imagine how this method works….

Example:
I created a very simple view with the following declarations:
In example 1, the background color of the panel gets green
In example 2, the background color of the panel remains black


Sub Globals
Dim Monitor As Panel
End Sub

Case 1)

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("HeartRate")
Monitor.Color = Colors.Green
End Sub

Case 2)

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("HeartRate")
Monitor.Initialize("Monitor")
Monitor.Color = Colors.Green
End Sub

Regards, Harald (Germany)
 

prokli

Active Member
Licensed User
Longtime User
Thanks for your very fast response!
Of course I know how to use "New" in VB / VB.Net. Usually it creates a object based on a class structure.
But why is the color of monitor set green in example 1 and why does it not work in example 2??
I suppose that I have created a new object which I could not see on my current activity??
Using the designer I have added a panel (named "Monitor") on the current activity. So if I execute "Monitor.Color = Colors.Green" this works fine.
But what happens if this is executed:

Monitor.Initialize("Monitor")
Monitor.Color = Colors.Green

Regards, harald
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Of course I know how to use "New" in VB / VB.Net.
You asked what Initialize did so I told you! You didn't say that it was VB.NET you were familiar with - it might have been VB6 so there's no need to get shirty with me.

I don't think that you have posted all the code because in neither case have you added Monitor to your Activity so you won't see it. If Monitor is being added by the Designer then you don't need to Iniaitialise it as LoadLayout does that for you.
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Sorry for confusing and.... I am not shirty!
Why should I??

I guess that I got it!
You are telling me: "If Monitor is being added by the Designer then you don't need to Iniaitialise it as LoadLayout does that for you"
That is what I was looking for!
Actually I added a panel to my project via designer and there is no need to initialize it.
That's it
thanks
 
Upvote 0
Top