new and need help

eben51

Member
Licensed User
Longtime User
Hey all,

I just found the "Basic4android" software and I'm using the trail version at the moment, thinking about buying it but want to try it out. I'm find it hard to find documentation on it. At the moment I'm trying make a public sub and call it but can't find the right code to do this any help would be nice...below is what I'm getting stuck, it's based off the code for the random number tutorial...

Sub Activity_Create(FirstTime As Boolean)
call TAB
End Sub

Sub TAB ()
Activity.LoadLayout("Laout1") 'Load the layout file.
MyNumber = Rnd(1, 100) 'Choose a random number between 1 to 99
End Sub
 

eben51

Member
Licensed User
Longtime User
Well I've programmed in both VB and RealBasic so I mean I'm new to this environment but have done visual basic type programming before.

a public sub, I mean instead of writing the same code over and over again, how do I write it once then call, in Realbasic you would write the code in a module. In VB you could write in a module or as "public sub" on a forum.

the first tutorial I seen was the random number guessing game. I wanted to make a reset button and I did so by adding this code...
MyNumber = Rnd(1, 100) 'Choose a random number between 1 to 99
twice once under the activity create_sub, then under a button_click sub, however how can I just write the code once and call it when needed
 
Upvote 0

eben51

Member
Licensed User
Longtime User
ok didn't see your attached file at first....

thanks, I see you how do this, you my code might have work if I didn't use
"call tab" just "tab" is all that's needed.

thanks
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Public subroutines are not yet supported in B4Android.
Have a look here.
http://www.b4x.com/forum/basic4andr...ls/6611-two-activities-example.html#post38694

The Android OS does work differently than Windows, to better understand Android 'Activities' this tutorial explains the details.
http://www.b4x.com/forum/basic4andr...87-android-process-activities-life-cycle.html

Subroutines can be called from anywhere within the an Activity but not from another one.

From the documentation point of view, don't forget that B4Android has been launched only 2 weeks ago. And documentation will come somewhat later. You can search in the forum to find answers to your questions or ask in the forum.

Best regards.
 
Upvote 0

eben51

Member
Licensed User
Longtime User
another question as I look at some of these tutorials, is there some way to load a scorlview with the designer...like add buttons and stuff
 
Upvote 0

eben51

Member
Licensed User
Longtime User
no scollview without coding in views...hummm
Well I'm kind of lazy with coding so let me ask this instead, is where way to multiple layouts within one program, was looking for an example of that but didn't see it.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can also define a layout in the Designer and add it to the ScrollView panel in the code, I have not tried it yet.

In the Designer you can define several layouts and the program when running on the device will choose the one that fits best the screen resolution.

Best regards.
 
Upvote 0
Top