STOP Go - Flow - Sub Activity_Create

MarkBasik4Android

Member
Licensed User
Longtime User
Hi, I am new and I know I have to learn...:sign0089:

I am doing tutorials and tests ..step by stem ...
I have read all the 2 PDF of B4A ...

But there is still a part missing, a General introducuon of ..... How does
Sub Activity_Create works?
:sign0080:

I understood that the "core" of the programming is this Sub "Activity_Create"
first we have variables and then we can have a lot of sub if something happens.. like a button or so...

So... This core Sub Activity_Create is Linear? ...(like old BASIC?)
One thing after the other?
I can load a first Activity.LoadLayout connect all buttons with sub...
OK but How to stop the flow waiting to go on? (I used BASIC...)

All the tutorials seem to stop on a first screen and on a single job!

What If I have to build an adventure "old style" like:
I touch here than I go there.. now I am in the room x and If i touch the toor..
I go to the door opening animation and then I go to the next room ....ecc...


In the Activity.LoadLayout...
How can I stop and wait to go to another Activity.LoadLayout ?

It is a wrong way to see this? Can someone explain in siple way? Thanks!
 

Penko

Active Member
Licensed User
Longtime User
Your Way of thinking is just a little old fashioned back from the Basic years. Activity Create is called when the Activity starts. This happens every time this activity is loaded. Normally, the first step is to load the layout. This initializes all labels from your designer. Please note you have to include them all in Globals but the Designer can do the job for you automatically. Everything is event-orientated. The Touch action is an event. It will only trigger if the user touches the screen. Activity pause is only called when this activity is being closed. Normally you save values and other stuff there. Clicking a button is also an event.

Sub BtnName_Click
' logic here
End Sub

I suggest you read the Wiki to understand what properties, events do B4A objects have. This will help you. The most used object events are Click and
LongClick. Labels and Buttons are examples for Views which support them.

LoadLayout only loads a layout. If you want to go to another activity, read about StartActivity and CallSubDelayed methods.

Normally, it is easiest that one activity is handled by one layout. An exception is when you have a master layout(e.g Tabhost)) and you have multiple layouts for each Tab.

Sent from my HTC Desire using Tapatalk
 
Last edited:
Upvote 0

MarkBasik4Android

Member
Licensed User
Longtime User
Your Way of thinking is just a little old fashioned back from the Basic years........
.......If you want to go to another activity, read about StartActivity and CallSubDelayed methods. ...... multiple layouts for each Tab.

Tank you... Yes I come from ...past...:sign0013:

But... please help me understand (i think is usefull also for all the others)

I usually make softwares with Adobe Director.. thai is like ...Basic.. and Building in Flash!
That is like..... mounting a time line in Premiere..
You have a line..... time, numbers, ecc... and you do things there.
When you press a button you say to Jump to another point of the "time Line".. ecc..

Here in B4A and in "modern" object oriented / event-orientated new WAY..things are different?

It is possible to explain this in simple way?

I have to build different "activity" and jump from one to another like in my " old fashioned " TIMELINE?
Different activity can have same layout or I have to build an Activity and "jump" to multiple "layouts"?

Is there a ABC books for children to understand way of ...programming in B4A?

P.S. I choos B4A because I want to build app and I Know I do not have time or patience to learn... java!:BangHead:
I have to quit?

thanks
 
Upvote 0

Penko

Active Member
Licensed User
Longtime User
Hmm, it's hard for me to explain it your way.

I suggest you start here:
http://www.b4x.com/forum/basic4android-getting-started-tutorials/6487-android-process-activities-life-cycle.html#post37980

Here is the timeline the way you mention it. It's based upon my own opinion.

Activity_Create -> Activity_Resume.

Here nothing more happens by system. Here starts the implementation of events.

If you click btnUser, the btnUser_Click event will be triggered.

If you long-click btnCancel, the btnCancel_LongClick event will be triggered.

Now you decide to press the Back key of your phone. This closes your activity, so the system calls the Activity_Pause Sub with the parameter UserClosed = True because it was a deliberate close.

Think of activities as different screens for your application.

In loginActivity you get the user/pass of the person.
In menuActivity you have some navigation -> profile, edit, add items

So each activity handles some tasks. Your activities may give out information to the user but they can also include edit texts(input fields) so the user has to type something.

I am sorry, but the old-fashioned timeline is not applicable here. Things are not time-oriented, they are event-oriented where events are time-independent. As long as your application is running a given Activity, the _Click event of any view will be triggered as many times as you click that View.

Klaus's beginner guide is the best summary of B4A which will throw light on how to start: http://www.b4x.com/android/files/guide.zip

Please get used to it and ensure you understand the topics there. Klaus has written most of it but Erel also contributed much. Some of the articles are ready tutorials from the forum. You just have to use the search tool. Most of the questions have already been asked and I find the answers very quickly myself.

I've been working with B4A for 5 months now and I can say it's my best software investment for the year of 2012. I was a big newbie at the beginning no matter I have rich Basic experience behind me. Hopefully, Erel and the community are patient enough and that's why I payback now by providing help :). The reason I purchased B4A was that it workarounds the Java approach which is what I like it for. I am now exploring Windows 8 and all languages are implemented there, from the .NET platform. I dunno why Android is Java-only but that's none of my business.

Sorry, I can't go simpler. Should you need more help, I'll try again.
 
Last edited:
Upvote 0
Top