Share My Creation Rem B4a Core

(SlimLine Menu used to get a program)

As already written in the last upgrade of my SlimLine Menu the experiment to scroll the menues was done to create an application to show the possible utilization of a dynamic complex object.
The one used in this program is quite different from the SlimLine Menu.
No more single or double menu but triple menu only with sliding capacity.
The menu uses 5 kinds of dynamic labels, 1 dynamic Panel and a dynamic WebView not included in the menu but needed to complete the application.

The program has been dedicatet to B4A as its name show ; Rem(ember) B4A core.
The pages contain all B4A views and the list of their events and their menbers.
These pages are consultable in local (without connection) but by wifi you can connect to see details of each member if you use the links therein.

About this i have question for Erel.
For the local pages i copied a part of code of your 4BA views (Core) and i used them as local pages. If this violate some right or copyright let me know and i shall change the program to operate on connection only.Take note anyway that this program will not be never published in any Market (except my site perhaps) and will be available here only if may be useful
In the meantime, going over, you can find here the code of the application.

Take note that the code in question does not require the use of the designer (and the resulting file main.bal) to operate as it uses dynamic views only.
The fact that, contrary to what is said, you will find in the program is only due to the need to provide units of measurement used by "AutoScaleAll".
In the file "main" in fact you will find only 2 label and 1 ImageView.
Two are used for the image and the inscription at the bottom of Actuvity and a. the lbl1, 8 x 100 dimension that provides the basic steps to create all the required elements of the dynamic program.
We start with

Sub Globals
Dim Mlist(10)
Dim Li(10)
Dim Labelio As Label
Dim ChoLab As Label
Dim Labase As Label
Dim Labmen As Label
Dim Labshow As Label
Dim PanMen As Panel
Dim WVx As WebViewExtras

Private Lbl1 As Label
Private Label2 As Label
Private ImageView1 As ImageView

Dim H As Int
Dim VM As Boolean
Dim No(10) As Int
Dim x, y, MeNo, t, KY, k, D As Int
Dim LG, Lista, Nlist As String
Dim ListM, listP As String
Dim Tx, LL, KX, KO As Int
Dim qq, BV, LN As Int
Dim Mn, n, m As Int
Dim mm As Int
Dim s, ListN As String
Dim Ch As Object
End Sub


The Sub "Create (FirstTime)" contains a reference to main.bal files and all strings in the form of Array created to store the data that the program will use.

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("main")

Mlist(0) = "A-B-C-D,E-F-G-H,I-J-K-L,M-N-O-P,Q-R-S-T,U-V-W-X,Y-Z-Note,Library,All B4a,"
Mlist(0) = "A-B-C-D,E-F-G-H,I-J-K-L,M-N-O-P,Q-R-S-T,U-V-W-X,Y-Z-Tutorial,Libraries,All B4a,"
Mlist(1) = "Activity,AutoC.EditText,Button,CheckBox, Cancel,"
Mlist(2) = "EditText,Horiz.ScrollView, Cancel,"
Mlist(3) = "ImageView,Label,ListView, Cancel,"
Mlist(4) = "Panel,ProgressBar, Cancel,"
Mlist(5) = "RadioButton,ScrollView,SeekBar,Spinner,TabHost,ToggleButton, Cancel,"
Mlist(6) = "View,WebView, Cancel,"
Mlist(7) = "Note, Cancel,"
Mlist(7) = "Tutorial List,Dynamic View(1),Dynamic View(2), Cancel,"
Mlist(8) = "All Libraries, Cancel,"
Mlist(9) = "All about B4A, Cancel,"

For h = 1 To Mlist(0).Length '(to calculate number Menu activable)
If Mlist(0).CharAt(h-1) = "," Then Mn = Mn + 1
Next
MeNo = Mn

For n = 1 To 9
For h = 1 To Mlist(n).Length '(to calculate number of items of each menu)
If Mlist(n).CharAt(h-1) = "," Then No(n) = No(n) + 1
Next
Next
D = 2*Lbl1.Height
VM = False
CreaBase
End Sub


In Sub indicated above also find some lines of code are not strictly necessary in a default version of programma.dove may be replaced by two appropriate values ??( and known )
These are the strings used by the routine to determine the number of required and the number of menu items for each menu that will be created .
These are useful for an automatic adjustment ogmi time you intend to variazioni.al program .
Andanfo found over the variable definische the height of a menu item indicated based on lbl1 reference VM and the boolean variable that tells the program if a menu is open or not.

The next Sub creates the frame to the line of the menu and has the task of controlling the scrolling of the menues

Sub CreaBase
For z = 1 To 2
Dim Base As Label
Base.Initialize("Labase")
Base.Visible = True
Base.SendToBack
Base.Tag = z
Base.Color = Colors.Blue
Activity.AddView(Base,(0dip + (z-1) * (2*Lbl1.Width-5*Lbl1.Height)), 0Dip, (2*Lbl1.Width- 5*Lbl1.Height), 4*Lbl1.Height)
'---------------------Activity.AddView(Base, (0+(z-1)*(160)), 0, 160, 32)--------------------
Next
Lista = Mlist(0)
mm = 0
CreaLio
End Sub


At the end of the Sub is called the Sub CreaLio that will create the menues by the parameters needed (mm and Lista)

Sub CreaLio
qq = Activity.NumberOfViews : BV = qq
For x = 1 To 3
Dim Lio As Label
Lio.Initialize("Labelio")
Lio.Visible = True
Lio.Color = Colors.White
Lio.TextColor = Colors.Black
Lio.TextSize = Lbl1.TextSize+2
Lio.Typeface = Typeface.DEFAULT_BOLD
Lio.Gravity = Gravity.CENTER_VERTICAL
Lio.Gravity = Gravity.CENTER_HORIZONTAL
Lio.Tag = x + mm
Activity.AddView(Lio,(Lbl1.Height-3dip) + (x-1) * (Lbl1.Width + 5dip), Lbl1.Height+6dip, Lbl1.Width,Lbl1.Height*2)
'---------------------Activity.AddView(Lio, (5+(x-1)*(105)), 14, 100, 16)--------------------
Tx = (Lista).IndexOf(",")
Lio.text = Lista.SubString2(0, Tx)
Nlist = Lista.SubString2(Tx+1, Lista.Length) '(remaining Lista string)
Lista = Nlist
Next
ListN = Nlist
qq = Activity.NumberOfViews : LN = qq-1
End Sub


The Sub CreaLio is the code I normally use to create lists of labels.
The difference in this case is that the list is horizontal and not vertical and that are compiled only the first 3 menu titles and 9 instead of all those requested.
Note that at the beginning and at the end of Sub are lines of code that count the view active and are necessary to carry out the cancellation when required

Since the program menu shows only 3 and only the first 3 are compiled at startup to be able to view the rest of you need to tap the left corner of the menu frame that triggers the following Sub

Sub Labase_Click
If VM = True Then Return
Dim Base As Label
Base.Initialize("Labase")
Base = Sender
Ch = Base.Tag
If Ch = 1 Then
If mm < 6 Then
mm = mm + 3
Lista = ListN
Else
If mm = 6 Then
Return
End If
Else
mm = 0
Lista = Mlist(0)
End If
End If
ClearList
CreaLio
End Sub


The code of this Sub reads via the object tag if the frame has been touched to the left or right , in the first case the code creates in sequence the subsequent 3 menus , at the end of the sequence by touching the right corner of the frame the same sub restores the menu from the beginning.

Now we can scroll through and see all the available menus but we also have to use them by enabling their lists retractable to select the required item.
To do this we need the following 2 Sub:

Sub Labelio_Click
If VM = True Then Return
Dim Lio As Label
Lio.Initialize("Labelio")
Lio = Sender
k = Lio.Tag
LL = Lio.Left
Creamenu
End Sub


This first sub enables the Click event on dynamic labels that show the menu titles, at the same time determines the Click event, reading the label tag. what is the menu in question and defines the coordinates that will be used from the list of menu used
It is then called the Sub Creamenu

Sub Creamenu
ListM = Mlist(k)
qq = Activity.NumberOfViews : BV = qq
For y = 1 To No(k)
Dim L1 As Label
L1.Initialize("Labmen")
L1.Visible = True
L1.Color = Colors.Cyan
L1.TextColor = Colors.Black
L1.Typeface = Typeface.DEFAULT_BOLD
L1.Gravity = Gravity.CENTER_HORIZONTAL
L1.Gravity = Gravity.CENTER_VERTICAL
L1.TextSize = Lbl1.TextSize
Activity.AddView(L1, LL, (Lbl1.Height*2) + y*(Lbl1.Height*2), Lbl1.Width, (Lbl1.Height*2))
'----------------------------Activity.AddView(L1, LL, 16+y*16, 100, 16)------------------------
Tx = (ListM).IndexOf(",")
LG = ListM.SubString2(0, Tx)
listP = ListM.SubString2(Tx+1, ListM.Length) '(remaining Lista string)
ListM = listP
L1.Text = LG : Li(y) = LG
Next


Dim Pan1 As Panel
Pan1.Initialize("PanMen")
Pan1.Enabled = True
Pan1.Visible = True
Pan1.Color = Colors.Transparent
Pan1.BringToFront
Activity.AddView(Pan1,LL, 4*Lbl1.Height, Lbl1.Width, (2*Lbl1.Height) * No(k))
'------------------------------Activity.AddView(Pan1, LL, 32, 100, 16)--------------------------
VM = True
End Sub


The Sub, in addition to creating list menu as seen from my early experiments ComboBox, overlaps it with a transparent panel that allows you to detect which item in the list is selected and also enabled (True), the Boolean variable VM preventing them from being activated more than menu at the same time.
After the above the PanMen_Touch Sub will allo you to select what you like and to show the result.

Sub PanMen_Touch (Action As Int, O As Float, V As Float)
If Action = Activity.ACTION_DOWN Then
KY = Round(V)
End If
Select Case True
Case KY < (D*1) : t = 1
Case KY < (D*2) : t = 2
Case KY < (D*3) : t = 3
Case KY < (D*4) : t = 4
Case KY < (D*5) : t = 5
Case KY < (D*6) : t = 6
Case KY < (D*7) : t = 7
End Select
ClearList
Dim SelLab As Label
SelLab.Initialize("ChoLab")
SelLab.Color = Colors.White
SelLab.Textcolor = Colors.Red
SelLab.TextSize = Lbl1.TextSize
SelLab.Typeface = Typeface.DEFAULT_BOLD
SelLab.Gravity = Gravity.CENTER_HORIZONTAL
SelLab.Gravity = Gravity.CENTER_VERTICAL
SelLab.BringToFront
SelLab.Visible = True
Activity.AddView(SelLab,LL, Lbl1.Height+6Dip, Lbl1.Width, (Lbl1.Height*2))
'-------------- -------------Activity.AddView(SelLab, LL, 14, 100, 16)---------------------------
SelLab.Text = Li(t) : Lbl1.Text = k & t
If SelLab.Text = " Cancel" Then
ChoLab_Click
Lbl1.Text = ""
End If
If SelLab.Text <> " Cancel" Then CreaWeb
End Sub


It should be noted that choosing the desired item on the list is closed and the selected item appears in the menu label of the title clicked.
This happens overlaying the existing label with a new label (SelLab)that shows the selected item.
This label also becomes the key to tap to close the results of the choice made. To do this the following Sub is used

Sub ChoLab_Click
qq = Activity.NumberOfViews : LN = qq-1
Dim W2 As WebView
W2.Initialize("WebView")
WVx.clearCache(W2,True) ' instruction for WebViewExtra to clear connection cache
W2.StopLoading
ClearList
VM = False
Lbl1.Text = ""
End Sub


Examining the Sub can be noted that in addition to signaling the closing of the menu list, via the variable VM, is also required the cancellation of the WebView dynamic that is used to show the result of the choice made by the menu.
The visualization takes place via the following Sub. (please note that, in the current code, Sub CreaWeb precedes the Sub ChoLab_Click obviously)

Sub CreaWeb
Dim W2 As WebView
W2.Initialize("WebView")
W2.Visible = True
W2.Color = Colors.LightGray
If Activity.Height > Activity.Width Then
Activity.AddView(W2, Lbl1.Height+4dip, Lbl1.Height*4,Lbl1.Width*3,Lbl1.Height*40)
'---------------------------Activity.AddView(W2, 12, 32, 300, 320)----------------------------
Else
Activity.AddView(W2, Lbl1.Height, Lbl1.Height*4,(Lbl1.Width*4+8*Lbl1.Height),Activity.Height-5*Lbl1.Height)

'---------------------------Activity.AddView(W2, 8, 32, 464, 280)----------------------------
End If

WVx.addJavascriptInterface(W2,"B4A")
WVx.addWebChromeClient(W2, "")
WVx.pageDown(W2,True)
WVx.pageUp(W2,True)

s = File.GetText(File.DirAssets,("Dat" & Lbl1.Text & ".html"))
W2.LoadHtml(s)
End Sub


As already written the Web View displays a local html page for each B4A view.
This page provides a brief description of the item and the list of its events and its members.
The page contains links that allow you to connect to the internet page of which the local one represents a partial summary.
The last 3 menues of the sequence allow only connection under WiFi to show the Libraries pages and many other information about B4A RAD Language.

Now there is only 1 sub that is still missing

Sub ClearList
qq = Activity.NumberOfViews : LN = qq-1
For m = LN To BV Step -1
Activity.RemoveViewAt(m)
Next
End Sub


This is a sub that i used several times and that allows using the number of the active views, checked by several Subs, to delete time by time dynamic views no longer needed.
Well, that's all, and while I apologize for my English, I hope that this little program can be useful for finding information on B4A even when you are away from your computer, or without connection.
You can find here attached the file .zip to use with B4A and the file .apk to install and see how the program works immediatly.(Attn the apk file has an Autoscale only for my Asus display at 1280 x 800) while has been developed on a GB 2.3.3 emulator. (320x480 160 base 1)
Have fun.
 

Attachments

  • RB4Ac.jpg
    RB4Ac.jpg
    30.4 KB · Views: 3,333
  • RB4Ac1.jpg
    RB4Ac1.jpg
    31.2 KB · Views: 159
  • RB4Ac2.jpg
    RB4Ac2.jpg
    31.1 KB · Views: 130
  • RB4Ac3.jpg
    RB4Ac3.jpg
    31.4 KB · Views: 144
  • RB4c5.jpg
    RB4c5.jpg
    52.5 KB · Views: 153
  • RB4c6.jpg
    RB4c6.jpg
    61.5 KB · Views: 143
  • RemB4Aslim-2bis.zip
    467.5 KB · Views: 127
  • remB4Aslim.apk
    146.1 KB · Views: 102
  • RB4Ac4.jpg
    RB4Ac4.jpg
    54.9 KB · Views: 150
Last edited:

Beja

Expert
Licensed User
efsoft,

This is double benefit.. a handy tool when using b4a offline or away from one's computer. And also it a very good example of a layout that b4a users can learn from it or modify it for their own layouts.. Indeed you spent a lot of time and efforts on this project to help others.

Thank you!
 

efsoft

Member
Licensed User
efsoft,

This is double benefit.. a handy tool when using b4a offline or away from one's computer. And also it a very good example of a layout that b4a users can learn from it or modify it for their own layouts.. Indeed you spent a lot of time and efforts on this project to help others.

Thank you!

Hi, Beja
and thanks again.
If what I did can also be useful to others is something that I hope.
This program was targeted to the actual use of multiple sliding menu and when I choose to apply it to B4A core I thought of me also because, sometimes, i need to refer to syntax, how to use the language etc not being connected.
The implementation is still rather rough and I will try in some way to improve it.
To the next.
 

efsoft

Member
Licensed User
There is something else to say.

As you can see above the code now shows the numerical value (in green), transcription of the dimensions passed to the "Activity.AddView" instruction using the measurements of the label lbl1, only View of the project created with the Designer.
As explained this procedure allows to use the AutoScaleAll method with dynamic objects.
However, there is still a problem.
The Sliding Multi Menu of the project Rem B4a has been developed on GB 2.3.3 320x480 160dip as Base 1, but to test the program on different O.S and screens the only possibility is to have several types of devices available.
It is impossible to use the UI Cluod system from the Designer to try to see how your layout applies to different (virtual) devices.
To solve this last case you can find here a file fakemain.bal that allows user to utilize the Cloud test.
In few words the layout of the file represents the Dynamic items created this time by the use of the designer, so it allow to use UI Cloud and to obtain correct result
Attached you find he file and some results images.
Samsung I900 - without autoscale use
Nexus 7 - AutoScaleRate 1.05 Valid for ASUS MemoPad HD 7 also
Samsung GT P1000 - AutoScaleRate 0.8 (no image)
Galaxy Note 5.3 - AutoScaleRate 1.05
 

Attachments

  • fakemain.bal
    4.5 KB · Views: 88
  • SamsungI9000.jpg
    SamsungI9000.jpg
    29.1 KB · Views: 100
  • Nexus7.jpg
    Nexus7.jpg
    32.6 KB · Views: 109
  • GalaxyNote5.3.jpg
    GalaxyNote5.3.jpg
    31.5 KB · Views: 100

efsoft

Member
Licensed User
Unexpected Evolution
Rem B4A
was born, as already mentioned, as a simple test to show how with a line of menu and a few other elements could create a useful program.
Also apply to the experiment language B4A was a random choice dictated by personal convenience of being able to see a part of the language even without a network connection.
While not expected this upgrade anyway includes program changes and content to make it a better tool.
Here's the changelog:
1)
to scroll through the contents of the menu now just tap anywhere on the blue frame (no more left or right) because now the rotation of the menu is continuous. (Reached the last we return to the first menu).
2) The menu that contains the list of links to tutorials available on the site (wifi connection required)
3) The same menu also features local 2 parts of the text that summarize directions to create, manage and delete dynamic objects (a kind of explanation of the similar programs already published)
4) For the first time, the possibility to rotate the tablet that allows a better reading of the linked pages and viewing of video tutorials (not all working with WebView used)
5) In the menu of the libraries has been added to the list of libraries normally included in iDE of B4A
For the moment, screen rotation does not preserve the contents of any external or local connection, and then you'll have to re-select the desired data if you decide to watch it horizontally.
Comments on the changes in the code .
The changes are indicated in the above code as follows:
Crossed line (code deleted and / or replaced)
Purple line ( new code related to changes above )
Nota0 : The data in Global and FirstRun are changed to correspond to the additions made to the content .
Note2: The creation of the WebView is conditioned by the ratio height/width of the activity to determine the rotation of the tablet ( and Screen ) In relation to the result is applied the size for the WebView .
The remaining dynamic objects (menu included) are adapted to the screen by the command AutoScaleAll but not adapted their measures to posiszione Landscape.
This is the first time that I apply the rotation ( even if partial) to dynamic objects.
 

Attachments

  • RemB4A-O1.jpg
    RemB4A-O1.jpg
    34.5 KB · Views: 96
  • RemB4A-O2.jpg
    RemB4A-O2.jpg
    64.5 KB · Views: 114
  • RemB4A-O3.jpg
    RemB4A-O3.jpg
    59.7 KB · Views: 118
  • remB4Aslim.apk
    161.9 KB · Views: 91
Last edited:

efsoft

Member
Licensed User
Dynamic views

Rem B4a has been created using dynamic views only.
In this connection i added to the available menu some notes about the use of such elements.
The text of these notes has not been carefully controlled being the program a simple trial for my use.
When, revising the matter, i found some little oversigths and some mistake (missing comma or point in the code etc)
I updated the text and, consequently i updated also the RemB4a.apk file.(the last published above)
Moreover if someone may be interested to the note in question, even if he does not like to use my program i add here:
The Note text as pdf file
A file .apk that, using the same code quoted into the note, allows you to see the dynamic views at work.
A folder, with the above program code, to see the full code applied, to utilize by B4A IDE to test and modify the code as you like.
(even the used view instead of the label as i done)
Have fun
 

Attachments

  • DynamicViews.pdf
    29.6 KB · Views: 130
  • dynamicsample.apk
    107.6 KB · Views: 87
  • DynamicSample.zip
    344.1 KB · Views: 97
  • DynViewTrial.jpg
    DynViewTrial.jpg
    25.3 KB · Views: 100
Top