Hello to all.
With my project 2014, born to learn something programming by the use of B4A, i tested many ways to use Dynamic Views to create single or complex elements by the direct use of the code,
What i present now is (as said) just an idea because there are some problems still to solve.
What is HelpG ? It is the possibility to assemble an help using Baloons created by dynamic elements to contain information concerning the views touched by the user into the Activity window.
To show what i mean the code you find here use some shortcut to show the final result.
In effects in this trial you may show each baloon by a long click event that is not the correct way to apply this kind of help to any object that you can use into your layout.
The application that you find here is based on a 320x480 screen only because the big problem is to make the method applied available automatically for any other kind of screen dimension.
But it is the time to see details.
First i created four images of a baloon with transparent background to load into files folder of the projects (format png)
Thence i addet to any view under the Long Click event the code to get position (left & Top) and dimension (heigth and width) of the existent .label or button.
So when you touch any item the data wil be passed. to the code that will create a dynamic imageview, will load the appropriate picture to use in that position and and will be created also a label into the baloon image to show the description selected for any element
But i think it is the time to pass to list the code used.
(may be a little confused but remember that this is an experiment only for the moment)
WARNING: This experimental code is now obsolete. Use the code below ("Evolution" message, no longer experimental)
And this is all.
A last thing: click on a baloon to close all.
To be true already exist an avolution that use a panel to select the objects and show their relative Help Baloons with any kind of views (without using LongClick) but the problems are the same:
The baloon images have a fixed dimension and this does not allows to automatically adapt the project to different displays.
In addition, There is somebody that know how to exstract the coordinates and the dimensions of the views from the Designer to use them directly with the code ?
We will see what will be possible to do.
Please note once again : to show the correct use load the project on a 320x480 B4A emulator only. The use of this experimet on a real device may not work correctly.Thanks
With my project 2014, born to learn something programming by the use of B4A, i tested many ways to use Dynamic Views to create single or complex elements by the direct use of the code,
What i present now is (as said) just an idea because there are some problems still to solve.
What is HelpG ? It is the possibility to assemble an help using Baloons created by dynamic elements to contain information concerning the views touched by the user into the Activity window.
To show what i mean the code you find here use some shortcut to show the final result.
In effects in this trial you may show each baloon by a long click event that is not the correct way to apply this kind of help to any object that you can use into your layout.
The application that you find here is based on a 320x480 screen only because the big problem is to make the method applied available automatically for any other kind of screen dimension.
But it is the time to see details.
First i created four images of a baloon with transparent background to load into files folder of the projects (format png)
Thence i addet to any view under the Long Click event the code to get position (left & Top) and dimension (heigth and width) of the existent .label or button.
So when you touch any item the data wil be passed. to the code that will create a dynamic imageview, will load the appropriate picture to use in that position and and will be created also a label into the baloon image to show the description selected for any element
But i think it is the time to pass to list the code used.
(may be a little confused but remember that this is an experiment only for the moment)
WARNING: This experimental code is now obsolete. Use the code below ("Evolution" message, no longer experimental)
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
Private Button2 As Button
Private Label1 As Label
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Dim LL, TT, WW, HH As Int
Dim K, BV, LN, qq As Int
Dim TXT As String [/B]
Dim Pictures(4) As String Array
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("main")
Pictures(0) = "Balo0.png"
Pictures(1) = "Balo1.png"
Pictures(2) = "Balo2.png"
Pictures(3) = "Balo3.png"
qq = Activity.NumberOfViews : BV = qq
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CreaBal
Dim IV As ImageView
IV.Initialize("ImageView")
IV.BringToFront
IV.Visible = True
IV.Bitmap = LoadBitmap(File.DirAssets,Pictures(K))
If K = 0 Then Activity.AddView(IV, LL, TT, 100dip, 100dip)
If K = 1 Then Activity.AddView(IV, LL-(100dip-WW), TT, 100dip, 100dip)
If K = 2 Then Activity.AddView(IV, LL, TT-(100dip-HH), 100dip, 100dip)
If K = 3 Then Activity.AddView(IV, LL, TT-(100dip-HH), 100dip, 100dip)
Dim LB As Label
LB.Initialize("Label")
LB.BringToFront
LB.Visible = True
LB.Color = Colors.White
LB.TextColor = Colors.Black
If K = 0 Then Activity.AddView(LB, LL+6, TT+35, 83, 42)
If K = 1 Then Activity.AddView(LB, LL+6+(WW-100), TT+35, 83, 42)
If K = 2 Then Activity.AddView(LB, LL+6, TT-(100-HH)+25, 83, 42)
If K = 3 Then Activity.AddView(LB, LL+7, TT-(100-HH)+24, 83, 42)
LB.TextSize = 8
LB.Text = TXT
qq = Activity.NumberOfViews : LN = qq-1
End Sub
Sub ImageView_click
Dim IV As ImageView
IV.Initialize("ImageView")
IV = Sender
ClearList
End Sub
Sub Label_Click
Dim LB As Label
LB.Initialize("Label")
LB = Sender
ClearList
End Sub
Sub Label1_LongClick
LL = Label1.Left
TT = Label1.Top
WW = Label1.Width
HH = Label1.Height
SetPos
TXT = "This is the First test of a Baloon Graphic Help"
CreaBal
End Sub
Sub Label2_LongClick
LL = Label2.Left
TT = Label2.Top
WW = Label1.Width
HH = Label1.Height
SetPos
TXT = "This is the Second test of a Baloon Graphic Help"
CreaBal
End Sub
Sub Label3_LongClick
LL = Label3.Left
TT = Label3.Top
SetPos
TXT = "This is the standard format for the graphic help in center and left side of the page"
CreaBal
End Sub
Sub Label4_LongClick
LL = Label4.Left
TT = Label4.Top
WW = Label1.Width
HH = Label1.Height
SetPos
TXT = "This is the standard format for the graphic left on right side"
CreaBal
End Sub
Sub Button1_LongClick
LL = Button1.Left
TT = Button1.Top
WW = Button1.Width
HH = Button1.Height
SetPos
TXT = "This is the Graphic help format on the right bottom side"
CreaBal
End Sub
Sub Button2_LongClick
LL = Button2.Left
TT = Button2.Top
WW = Button2.Width
HH = Button2.Height
SetPos
TXT = "This is the Graphic help format on the left bottom side"
CreaBal
End Sub
Sub SetPos
If LL < 160 AND TT < 340 Then K = 0
If LL > 160 AND TT < 340 Then K = 1
If LL < 160 AND TT > 340 Then K = 2
If LL > 160 AND TT > 340 Then K = 3
End Sub
Sub ClearList
qq = Activity.NumberOfViews
For m = LN To BV Step -1
Activity.RemoveViewAt(m)
Next
TXT = "" : K = 0 : LL = 0 : TT = 0
End Sub
And this is all.
A last thing: click on a baloon to close all.
To be true already exist an avolution that use a panel to select the objects and show their relative Help Baloons with any kind of views (without using LongClick) but the problems are the same:
The baloon images have a fixed dimension and this does not allows to automatically adapt the project to different displays.
In addition, There is somebody that know how to exstract the coordinates and the dimensions of the views from the Designer to use them directly with the code ?
We will see what will be possible to do.
Please note once again : to show the correct use load the project on a 320x480 B4A emulator only. The use of this experimet on a real device may not work correctly.Thanks
Attachments
Last edited: