AHActionBar Library

corwin42

Expert
Licensed User
Longtime User
This library is deprecated. If you develop for Android 3.0 and above (API11) you should use the StdActionBar library and the StdActionBarHelper library for customizing the ActionBar.

Development has stopped on this library.



This library provides an ActionBar object. With this object it is possible to create an ActionBar like in Android 3.0 and above. This library is NOT a wrapper to the standard Android ActionBar available in Android 3.0 and above but it is a complete custom implementation.

The object is highly based on a free ActionBar implementation by Johan Nielsson. I had to make many modifications to get it usable for B4A.

The original library has some more features that are currently not exposed to B4A. This may be done in the future.

This library is somewhat different to other libraries because it makes use of standard Android resource files. Resource files cannot be published inside a .jar file and so you have to copy them to your Basic4Android project directory.

Copy the whole "res" directory structure to the "Objects" directory of your B4A project and VERY IMPORTANT: make all the files in it READ ONLY! Otherwise B4A will delete them when compiling. After you make any change to the Objects/res directory use "Clean project" menu item in B4A to force the compiler to recreate the R.java file.

If you forget to make the resource files read only then you will most likely get a ResourceNotFound exception when you try to use the ActionBar.

Installation:
- Copy the .jar and .xml files to your custom libs folder
- Copy the res directory structure to <Your project folder>\Objects\res
- Make all files in <Your project folder>\Objects\res\xxx read only
- If you import this into an existing project use "Clean project" menu in B4a to force update of resource java files.

History:
v1.00
- initial version
 

Attachments

  • AHActionBar1_0.zip
    51.6 KB · Views: 2,441
  • AHActionBarExample1_0.zip
    40 KB · Views: 2,065
  • 2012-02-15 23.10.48.jpg
    2012-02-15 23.10.48.jpg
    11.4 KB · Views: 3,343
Last edited:

boastrike

Member
Licensed User
Longtime User
Until such time when they organize the first Basic4Android User's Conference and I get a ticket to it, I am forced to give my humble thanks to you for not only taking the time to write libraries like this one but then take the time to explain them and share them with us on here. Awesome job on this one and it solves problems instantly that I was struggling on my own.

Thank you very much! Jim :sign0188:
 

susu

Well-Known Member
Licensed User
Longtime User
Very nice! I love it so much. Thank you Markus.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Awesome!

Hi,

Another great piece of work from your hand!

Just one question, does it work on ICS when the menu is top right? Did not had time to test that.

I love it!
 

bluedude

Well-Known Member
Licensed User
Longtime User
Does not support menu items

Unfortunately this does not support the standard menu options in Icecream Sandwich.

I'm trying to create interfaces according to the new Google guidelines (which are very good) and because this isn't a real action bar it does not play well with the menu items that appear top right in ICS.

Although I love it i'm don't want to use the non standard Quick Actions as a menu (they simply look different).

Any other options to make this work? Is there a way to add menu items the normal way and display them through the ActionBar click event?
 

bluedude

Well-Known Member
Licensed User
Longtime User
Alright, I can use Activity.Openmenu but the menu displays in the wrong position, top bottom middle. I should be top right.

So this action bar conflicts with the menu items.

Can this be fixed?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Alright, I can use Activity.Openmenu but the menu displays in the wrong position, top bottom middle. I should be top right.
Really? top bottom middle? :sign0094:
how about a screenshot.
EDIT: btw...you can use AHQuickActions with this.
 
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
thedesolatesoul

Don't want to use another exotic menu because I want to comply with the Android design guidelines so that is not an option for me. I need an action bar that also supports the standard menu.

Not saying I don't like the action bar (I use the other one for fast actions) but it needs to support the standard menu options.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Menu options in the middle of the screen

Hi,

When I use the action bar and then trigger an action item to do Acitivity.openmenu the menu items appear in the wrong place. See the screenshot.
 

Attachments

  • Screenshot_2012-02-17-09-47-41[1].jpg
    Screenshot_2012-02-17-09-47-41[1].jpg
    7.2 KB · Views: 784

corwin42

Expert
Licensed User
Longtime User
Excellent work corwin42 :sign0188:
Is it possible to change the scrollspeed of the title? I am trying to use it as a scrollable label :)
Also is it possible to change the Typeface of the Title?

The title is a slightly modified textview with the marquee effect (the scrolling). The modification is only that the text scrolls even if the view is not focused. Unfortunately I don't think that there is a way to change the scrolling speed but I think with Reflection it should be possible to use the scrolling effect in every B4A TextView where the text does not fit into the view.

Changing the title style should be possible with agrahams RichString library but I haven't tried it.

@bluedude:
I am totally aware that this ActionBar is not compatible with the HC or ICS ActionBar. I have looked at some other examples which were compatible with the HC/ICS ActionBar. Unfortunately ActionBarSherlock for example requires to extend from FragmentActivity and not just Activity. So this can't be used with B4A. Another one was the ActionBarCompat example from google. This one needs some initialization code in onPostCreate() of the activity and this is not exposed in B4A. I don't know if it would be possible to use it with reflection but even this would be quite complicated to handle. So currently I don't see the possibility to implement an ActionBar that is fully compatible with HC/ICS ActionBar and also runs on older devices with Android < 3.0.
 

corwin42

Expert
Licensed User
Longtime User
Hi,

When I use the action bar and then trigger an action item to do Acitivity.openmenu the menu items appear in the wrong place. See the screenshot.

I'm not 100% shure but I think this can't be changed. If you use the HC/ICS ActionBar then the menu items are converted to Actions and therefore is not a normal menu anymore.
 

thedesolatesoul

Expert
Licensed User
Longtime User
The title is a slightly modified textview with the marquee effect (the scrolling). The modification is only that the text scrolls even if the view is not focused. Unfortunately I don't think that there is a way to change the scrolling speed but I think with Reflection it should be possible to use the scrolling effect in every B4A TextView where the text does not fit into the view.

Changing the title style should be possible with agrahams RichString library but I haven't tried it.
Yes, the title style does indeed change using agraham's RichString library.
Thanks a lot!
 

Inman

Well-Known Member
Licensed User
Longtime User
Excellent library. Started using it in one of my projects and it really uplifts the UI.

Is it possible to set the title text aligment (gravity)?
 

corwin42

Expert
Licensed User
Longtime User
Is it possible to set the title text aligment (gravity)?
This is currently not possible.

I don't know if it is possible to access private fields with reflection. If yes then it may be possible with reflection but it would be quite complicated.
 

Inman

Well-Known Member
Licensed User
Longtime User
Will it be possible to implement adding labels instead of images, to actionbar? Like how IMDb has on their app.

dEjXc.jpg
 
Top