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,784
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
and no one is under any obligattion to donate to your paypal account either.

I was thinking the same thing when I saw Informatix's post. :D

I think you guys got the wrong end of the stick. A bit of a translation issue. It happens from time to time when english isn't the home language. I think Informatix was saying he has no problem helping Beginners out.
 

Informatix

Expert
Licensed User
Longtime User
I was thinking the same thing when I saw Informatix's post. :D

It's not the first time I talk with wheretheidivides. And I'm not sure I really want to help him due to our past talkings. It's something personal here. I have nothing at all against beginners. I think I posted enough messages to prove that.

It's very irritating to read his posts because of his lack of diplomacy. And I don't want to be more diplomatic with him as he is with me. Do you think it was a good idea to start a post with a reminder about the B in Basic?

And if you think that I don't deserve any donation for my work or for the time spent here to help other people, I won't argue against your opinion. You're free to not use my work, to not read me, to not benefit from my tutorials. You're even free to think that my work is crappy and that you can do better. Maybe some day, you will show us some classes, libraries or tutorials that really deserve our attention...
 

Informatix

Expert
Licensed User
Longtime User
I opened the demo up but it wouldn't run. Says refector isnt there or something. So to answer your and erel's questions, yes we do read stuff before asking questions. it's just the people writing stuff are writing for advanced users.

The Reflection library may be found here.

When you look for a library, there's a list here.

You'll find two files in the zip file: a .jar and a .xml. Both must be copied into your additional lib folder. This folder is set in the Paths Config dialog of the B4A IDE.
 

bluedude

Well-Known Member
Licensed User
Longtime User
The B...

stands for Be polite.

And I think that some posts are pretty hard to read because it isn't always easy to write in English for many forum visitors.

Cheers,
 

marcel

Active Member
Licensed User
Longtime User
Hi,

Great work!!

Am I able with this to build something as in my attachment (button bar below)?
 

Attachments

  • bar.jpg
    bar.jpg
    92 KB · Views: 347

marcel

Active Member
Licensed User
Longtime User
No problem. You can do the three button bars of your screenshot. Look at this tutorial to know how to customize the button appearance.

Small question. Do you have a downloadable source code of that example? Or can you explain to me the background image of the button bar? Is this 1 line width and will be expanded automaticly based on the size of the device? Or is this a very width image? Is this resized automaticly? What is the best way to do this?
 

marcel

Active Member
Licensed User
Longtime User
Some issues with images

Hi,

I have made a simple test. It seems to work out ok. Only I have an issue with the images. They seems to be stretched. Can I switch this off? Or are my pictures not correct? If not what is the correct size? :sign0013:
 

Attachments

  • bar2.png
    bar2.png
    39 KB · Views: 329

Informatix

Expert
Licensed User
Longtime User
Small question. Do you have a downloadable source code of that example?

No. But 99% of the code is included in the tutorial.

Or can you explain to me the background image of the button bar? Is this 1 line width and will be expanded automaticly based on the size of the device? Or is this a very width image? Is this resized automaticly? What is the best way to do this?

"bg_defaut.png" is just two pixels wide and is stretched automatically.
 

marcel

Active Member
Licensed User
Longtime User
Use only square images. Add a transparent padding around them to make them squared.

They are 30*30 pixels. I have attached a sample.
 

Attachments

  • mailbox-icon.png
    mailbox-icon.png
    879 bytes · Views: 330
Last edited:

marcel

Active Member
Licensed User
Longtime User
No. But 99% of the code is included in the tutorial.

"bg_defaut.png" is just two pixels wide and is stretched automatically.

Ok. I have always problem with images. I am not sure what happen to them. If they are resized depending on the screen size? Or do I need to have a set of images depending on the screen size.
 

Informatix

Expert
Licensed User
Longtime User
Sure, Attached the project file.

I see nothing wrong. The displayed images are perfect squares on my devices and they are perfect squares also on your screenshot, so I don't see what's the problem exactly.

Note: if you enable SameWidthForAll, the icons will be enlarged or reduced to fit the action bar width, but they will be only rescaled, not stretched. If they are squared, they remain squared.
 
Last edited:

marcel

Active Member
Licensed User
Longtime User
Note: if you enable SameWidthForAll, the icons will be enlarged or reduced to fit the action bar width, but they will be only rescaled, not stretched. If they are squared, they remain squared.

If you look to the icons f.e. in paint.net or on the screenshot they look more expanded. I am not sure how to explain this. But it is not sharp anymore.

I did get the impression that the SameWidthForAll had to with the size of the buttons? So it resizes the buttons and the images? Can I use a seperate function to influence this enlargement?

Sorry about all the questions.... :sign0013:
 

Informatix

Expert
Licensed User
Longtime User
Can I use a seperate function to influence this enlargement?

Sub SetFixedWidth(Btn As View, NewWidth As Int)
'Sets the button width and centers its content
'This new width is temporary. It will be reset if you call Invalidate or a function modifying the button content.
'This function is ignored if SameWidthForAll has been enabled.

Sub SetIconAsWideAsText(Enabled As Boolean)
'Enlarges the icon to fit the text width
'This function is ignored by buttons with no text and buttons with a text on the left/right side.
 

marcel

Active Member
Licensed User
Longtime User
Sub SetFixedWidth(Btn As View, NewWidth As Int)
'Sets the button width and centers its content
'This new width is temporary. It will be reset if you call Invalidate or a function modifying the button content.
'This function is ignored if SameWidthForAll has been enabled.

Sub SetIconAsWideAsText(Enabled As Boolean)
'Enlarges the icon to fit the text width
'This function is ignored by buttons with no text and buttons with a text on the left/right side.

Thanks, solved the issues.
 
Top