Hi there,
I've ordered B4A just a few weeks ago and i must say: i'm really happy with this powerful language and the
outstanding support in this forum. And here it is, my first B4A Code Module. I hope, some will find it useful.
toolbar.bas is an Easy-To-Use Toolbar: 5 Lines of Code in your Sub Main are enough to make it work.
Features:
-Alignment(Left,Centered and Right) on Top or Bottom of the Activity.
-Click and HighLight Events
-2-State Buttons(Play/Pause, Checked/Unchecked etc.)
-Skin-Support: Layout can be changed at Runtime.
-Scalable Size
ToolbarDemo1 is a minimal Program with just 9 Lines of Codes.
ToolbarDemo2 is a little bit more complex and shows, how to configure the Toolbar manually.
If you have any suggestions, let me know.
Enjoy.
Regards,
Joerg
How to use the Toolbar in your Code:
1. Add the Toolbar Code Module to your Project (Project->Add Existing Module)
2. Add the following Images to your Files Folder:
toolbar_blank.png (the Button Image without any Icon/Text)
toolbar_highlight.png (the highlighted Button Image without any Icon/Text, same size as toolbar_blank.png)
toolbar_texture.png (the Toolbar Background Image, should have same Height as toolbar_blank.png)
3. Add as many transparent Icons as you need, to your Files Folder (with the same size as toolbar_blank.png)
toolbar_1.png
toolbar_2.png
toolbar_3.png
etc...
Optionally, add Icons for Two-State-Buttons, for Example:
toolbar_2a.png (this will automatically make the second Button a 2-State Button)
etc...
4. Add the following Code to your Sub Main:
5. Add the following Events to your Sub Main:
I've ordered B4A just a few weeks ago and i must say: i'm really happy with this powerful language and the
outstanding support in this forum. And here it is, my first B4A Code Module. I hope, some will find it useful.
toolbar.bas is an Easy-To-Use Toolbar: 5 Lines of Code in your Sub Main are enough to make it work.
Features:
-Alignment(Left,Centered and Right) on Top or Bottom of the Activity.
-Click and HighLight Events
-2-State Buttons(Play/Pause, Checked/Unchecked etc.)
-Skin-Support: Layout can be changed at Runtime.
-Scalable Size
ToolbarDemo1 is a minimal Program with just 9 Lines of Codes.
ToolbarDemo2 is a little bit more complex and shows, how to configure the Toolbar manually.
If you have any suggestions, let me know.
Enjoy.
Regards,
Joerg
How to use the Toolbar in your Code:
1. Add the Toolbar Code Module to your Project (Project->Add Existing Module)
2. Add the following Images to your Files Folder:
toolbar_blank.png (the Button Image without any Icon/Text)
toolbar_highlight.png (the highlighted Button Image without any Icon/Text, same size as toolbar_blank.png)
toolbar_texture.png (the Toolbar Background Image, should have same Height as toolbar_blank.png)
3. Add as many transparent Icons as you need, to your Files Folder (with the same size as toolbar_blank.png)
toolbar_1.png
toolbar_2.png
toolbar_3.png
etc...
Optionally, add Icons for Two-State-Buttons, for Example:
toolbar_2a.png (this will automatically make the second Button a 2-State Button)
etc...
4. Add the following Code to your Sub Main:
B4X:
Sub Globals
Dim cnv As Canvas
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime then Toolbar.Initialize
cnv.Initialize(Activity)
Toolbar.Draw(Activity,cnv,0)
End Sub
Sub Activity_Touch(Action as Int, X As Float, Y As Float)
Toolbar.Touch(Activity,cnv,Action,x,y)
End Sub
5. Add the following Events to your Sub Main:
B4X:
Sub Toolbar_Click(ButtonIndex As Int)
End Sub
Sub Toolbar_Highlight(ButtonIndex As Int)
End Sub