B4A Library [Class] ActionBar

Discussion in 'Additional libraries, classes and official updates' started by Informatix, Aug 23, 2012.

  1. Informatix

    Informatix Expert Licensed User

    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
     

    Attached Files:

    Last edited: Jun 18, 2014
    DroidLyon, walt61, thecid_ia and 10 others like this.
  2. bluedude

    bluedude Well-Known Member Licensed User

    Nice

    Pretty interesting, how can I change text size of buttons etc.?
     
  3. Informatix

    Informatix Expert Licensed User

    YourActionBar.SetText

    Code:
    'Sets text of the given button
    'You can set TextColor and TextSize to -1 to left them unchanged
    Public Sub SetText(ID As View, Text As String, TextColor As Int, TextSize As Int)
     
    Last edited: Aug 23, 2012
  4. bluedude

    bluedude Well-Known Member Licensed User

    Mmm,

    If I have this like in your sample AB2.AddButton(LoadBitmap(File.DirAssets, "home.png"), "HOME", 7, 1, "", "Home_LongClick")

    How can I set the Textsize then? AB2.SetText and then? What is the ID of the View and how can I exactly know the ID of the view?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Great work! Thank you for sharing this.
     
  6. Informatix

    Informatix Expert Licensed User

    The AddButton function returns the button ID (as explained in the function help). But, in the demo, I don't need to do something with the returned value most of the time so I don't store it. If you get it, you can use it to modify the button. The demo includes an example of use:
    Code:
    Dim Btn As View
             Btn = AB.AddButton(
    LoadBitmap(File.DirAssets, "home.png"), ""21"""Home_LongClick")
             AB.SetText(Btn, 
    "Home"Colors.Yellow, -1)
     
  7. Informatix

    Informatix Expert Licensed User

    If someone wants to include nice graphics in the action bar (not detected as buttons, of course), this is very easy:
    YourActionBar.AsPanel.AddView(YourImageView, ....

    That works with all kind of views, except labels (reserved for the title) and panels (reserved for the buttons).
     
  8. moster67

    moster67 Expert Licensed User

    Thanks for sharing. Looks awesome.
     
  9. Informatix

    Informatix Expert Licensed User

    New version (v1.1):
    Fixed a bug in RemoveButton
    Added ReplacePressedDrawable
    Fixed a bug in the demo (tab style)
     
  10. corwin42

    corwin42 Expert Licensed User

    Hey, nice work. I have thought about implementing an action bar as a class some days ago. Now you have done it.

    Thanks for sharing.
     
  11. dealsmonkey

    dealsmonkey Active Member Licensed User

    Thank you for this looks brilliant.
     
  12. BarrySumpter

    BarrySumpter Active Member Licensed User

    Combined ActionBar with AHQuick Action Menus

    Jeez! Thats nice!

    By the way the Ribbon Action Bar scrolls.
    Brilliant!
     

    Attached Files:

    thecid_ia likes this.
  13. Informatix

    Informatix Expert Licensed User

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

    With SetIconAsWideAsText, it's now possible to have tabs like the ones in the Android article on Action bars.

    Starting tomorrow, I will publish tutorials to show how to use my classes and my libraries to replicate the UI of some applications made by professionals. That will show you some advanced techniques. For copyright reasons, that will be only text and screenshots. ;-)
     
  14. JonPM

    JonPM Well-Known Member Licensed User

    Thanks! Great class!
     
  15. Informatix

    Informatix Expert Licensed User

    New version (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)
     
  16. Mahares

    Mahares Well Known Member Licensed User

    @Fred: Although your CLASSES are very classy, I am getting confused, because you mentioned in one you posts that you have combined the FLoatingWindows and Actionbars or as you referred to a (split). But I still see 2 separate classes. Could you please clarify the confusion or set me in the right track?
    Merci
     
  17. Informatix

    Informatix Expert Licensed User

    These two classes were only one at the beginning. Now, they live their own lives. I never said I have combined them.
     
  18. Informatix

    Informatix Expert Licensed User

    New version

    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
     
  19. mitsusdev

    mitsusdev Active Member Licensed User

    Great Work! Thx for share.:sign0098:
     
  20. mrossen

    mrossen Active Member Licensed User

    Very Nice,

    I have a simple question.

    Have you made any functions for the overflow menu? The right menu with the 3 dots.

    I would like to have 2 icons and the overflow icon on the bar. And under the overflow menu 5 other menu points. Is this possible.

    Mogens
     
    Last edited: Oct 3, 2012
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice