B4A Library [Class] ActionBar

Hi,

This class allows to create Action Bars.

There was already a good library to do that (AHActionBar) but I needed more features and more flexibility. So here is my version.

Tutorials: How they do #2, How they do #3

Classic.png Menu.png Tab.png Ribbon.png
DragAndDrop.png

v1.1:
Fixed a bug in RemoveButton
Added ReplacePressedDrawable
Fixed a bug in the demo

v1.2:
New functions:
- ReplaceDividerDrawable(Drawable As Object)
- SetIconAsWideAsText(Enabled As Boolean)
Updated the demos

v1.3:
Fixed a bug in ResizeButton (the text height was not correctly computed)
New function: FillParent
Removed the limitation of SetFixedWidth (there's no longer minimum width)

v1.4:
Optimized the loading of drawables
Added the Drag&Drop feature
New functions:
- getLeftPosition(Btn As View) As Int
- getRightPosition(Btn As View) As Int
- StartDragAndDrop(Btn As View, ViewToBlock As Object, OnAfterDropSub As String)
- AbortDragAndDrop
- MoveButtonTo(Btn As View, NewPosition As Int)
Renamed ID to Btn in function parameters

v1.41:
Fixed an issue with JellyBean.
Fixed a visual bug with successive Drag&Drops.

v1.42:
Fixed the computation of the text size of buttons;
No more warnings with B4A v2.7.

v1.43:
Fixed a bug (division by zero).

Enjoy,
Fred
 

Attachments

  • ActionBar v1.43.zip
    62.8 KB · Views: 1,790
Last edited:

b4auser1

Well-Known Member
Licensed User
Longtime User
Is it possible to show Title text and Sub-title below the Title like it's done in AHActionBar ?
Is it possible to attach a tag to Button in order to have one OnClickSub for AppButton with two different icons: with and without caret. It will allow to perform different actions in the same OnClickSub, based on this tag ?
 

Informatix

Expert
Licensed User
Longtime User
Is it possible to show Title text and Sub-title below the Title like it's done in AHActionBar ?
Is it possible to attach a tag to Button in order to have one OnClickSub for AppButton with two different icons: with and without caret. It will allow to perform different actions in the same OnClickSub, based on this tag ?
Yes, all this is possible; you have the full source code so modify it as you wish.
 

CidTek

Active Member
Licensed User
Longtime User
Using the Actionbar in tab mode how do I programatically change the tab_selected and tab_ normal icons on existing buttons to their last state (device rotation for example) without recreating the buttons?

EDIT: Oops I asked too soon and found the ReplaceIcon sub.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I have not read all the posts, so maybe I will repeat a question already present in this thread.

In the "Menu" style, every time you add a new button, they are resized; why not scroll through them, as is the case with the "Ribbon" style? Or the Ribbon can be placed on top?
 

Informatix

Expert
Licensed User
Longtime User
I have not read all the posts, so maybe I will repeat a question already present in this thread.

In the "Menu" style, every time you add a new button, they are resized; why not scroll through them, as is the case with the "Ribbon" style? Or the Ribbon can be placed on top?
These styles are just different settings passed to the class.
If you want to place the "ribbon" at the top, just change the position of the view.
 

LucaMs

Expert
Licensed User
Longtime User
These styles are just different settings passed to the class.
If you want to place the "ribbon" at the top, just change the position of the view.

Ehm, i need to read the code ;) but i guess then i can't obtain "scrolling buttons" just setting something in the activity that uses your class.
(but i can modify the class to do that :)).

Thanks, Informatix
 

wizard699

Active Member
Licensed User
Longtime User
Hi.
It's possibile to set textsize for all buttons in one line of code?
Or we make it for each button that we add?
 

RjCl

Member
Licensed User
Longtime User
Hello Informatix,

Is it possible to load a different layout with a button in the main layout ?
B4X:
Sub Button1_Click

    Activity.LoadLayout("webviewlayout.bal")
    Webview1.Initialize("")
    Webview1.LoadUrl("http://www.google.co.uk")

End Sub

It loads but not displaying anything in the WebView? Also in the Button1_Click how to make another Tab as being selected? Say the button is clicked when 'Home' is selected, then loads another layout, but also change Tab selected to 'Favorites' ?
 

Douglas Farias

Expert
Licensed User
Longtime User
Informatix all devices have dark theme?

this class have a os limitation?
 

Informatix

Expert
Licensed User
Longtime User
Hello Informatix,

Is it possible to load a different layout with a button in the main layout ?
B4X:
Sub Button1_Click

    Activity.LoadLayout("webviewlayout.bal")
    Webview1.Initialize("")
    Webview1.LoadUrl("http://www.google.co.uk")

End Sub

It loads but not displaying anything in the WebView? Also in the Button1_Click how to make another Tab as being selected? Say the button is clicked when 'Home' is selected, then loads another layout, but also change Tab selected to 'Favorites' ?
1) Layout: It's either a problem with WebView or with your programming, but not with the class. What happens after a click does not depend on the class.
2) Tab: In the demo, call the Tab_Click function to change the tab. As I did not memorize the button reference, you will have to declare Dim BtnFavorites As View in Globals and assign the result of AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Favorite"... to it, so you will be able to pass the button reference to Tab_Click.
 

pesquera

Active Member
Licensed User
Longtime User
Hi, I'm trying to use this wonderful class. I'm not using the designer. The panel with the action bar is ok, but is displayed below the activity's
title. How can I do to put the action bar on the place of the activity's title?
B4X:
    pnlAB.Initialize("pnlAB")
    Activity.AddView(pnlAB, 0dip, 0dip, 100%x, 50dip)
    AB.Initialize(pnlAB, True, True, pnlAB.Height, Me)
 

Informatix

Expert
Licensed User
Longtime User
Hi, I'm trying to use this wonderful class. I'm not using the designer. The panel with the action bar is ok, but is displayed below the activity's
title. How can I do to put the action bar on the place of the activity's title?
B4X:
    pnlAB.Initialize("pnlAB")
    Activity.AddView(pnlAB, 0dip, 0dip, 100%x, 50dip)
    AB.Initialize(pnlAB, True, True, pnlAB.Height, Me)
In the Activity Attributes of your activity, set #IncludeTitle to False.
 

Bonzai543

Member
Licensed User
Longtime User
I upgraded to Android 4.4.3 and now I am getting an error in the demo in the "UpdateBackground" sub:
java.lang.IllegalArgumentException: unknown bitmap configuration

It worked fine with Android ver 4.4.2 Any Ideas?
 
Top