B4A Library StdActionBarHelper - Utilities for the Standard ActionBar

This library adds some features to the Standard ActionBar. It uses the native ActionBar which is available with Android 3+ (API 11 and above).

The main reason I wrote this library was to add support of changing the up indicator of the actionbar so you can change it to the navigation drawer indicator.

The implementation for this is similar to the one found in the Google Android support library. It uses native methods with API18 and above. If the device has a lower API level a "hack" is used to find the imageview of the up indicator. This may not work on all devices (if the device manufacturer changed the ActionBar implementation on the device).

There are some additional methods to hide the title/appicon etc. from the ActionBar.

With version 1.10 of this library there are many new objects:

ActionMode - Create a contextual ActionBar
Menu and MenuItem - Used to create and modify the menu in the contextual ActionBar
PopupMenu - Create a popup menu like the standard overflow menu.
SearchView - This is for an experimental feature for which I will have to write a new tutorial. With this object it is possible to add a standard SerachView to the ActionBar. But it is quite complicated to use (you will have to change generated B4A Java source etc. So this is really for the advanced user). For now you should ignore this object.

There are a few examples:

ActionModeExample - Example for the contextual ActionBar (ActionMode). This even shows how to modify the menu of the contextual ActionBar.
PopupMenuExample - Show the usage of the PopupMenu object
ActionModePopupExample - Combines ActionMode and Popup Menu
NavDrawerStdActionBarExample - Shows how to use the NavigationDrawer together with the standard ActionBar.

The examples (mainly the NavDrawerExample) use some additional libraries:
- AHNavigationDrawer
- b4amListView
- StdActionBar
- XmlLayoutBuilder
 

Attachments

  • StdActionBarHelper1_10.zip
    16.7 KB · Views: 2,780
  • ActionModeExample.zip
    19.7 KB · Views: 1,846
  • ActionModePopupExample.zip
    20.2 KB · Views: 1,877
  • PopupMenuExample1_00.zip
    15.6 KB · Views: 1,929
  • NavDrawerStdActionBarExample1_2.zip
    328.2 KB · Views: 2,274
Last edited:

bermooda

Member
Licensed User
Longtime User
Hi
i tried to test your lib, but i got exception on
B4X:
NavDrawer.Initialize("Drawer", pContent, 240dip)
line 54
message:
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: de.amberhome.navdrawer.DrawerLayout$ViewDragCallback
at de.amberhome.navdrawer.DrawerLayout.<init>(DrawerLayout.java:232)
at de.amberhome.navdrawer.DrawerLayout.<init>(DrawerLayout.java:222)
at de.amberhome.navdrawer.DrawerLayout.<init>(DrawerLayout.java:218)
at de.amberhome.navdrawer.NavigationDrawer.Initialize2(NavigationDrawer.java:84)
at de.amberhome.navdrawer.NavigationDrawer.Initialize(NavigationDrawer.java:63)
at de.amberhome.navdraweractionbar.main._activity_create(main.java:327)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:174)
at de.amberhome.navdraweractionbar.main.afterFirstLayout(main.java:98)
at de.amberhome.navdraweractionbar.main.access$100(main.java:16)
at de.amberhome.navdraweractionbar.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5144)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)

is there anything I'm missing?
 

corwin42

Expert
Licensed User
Longtime User
Hi
i tried to test your lib, but i got exception on
B4X:
NavDrawer.Initialize("Drawer", pContent, 240dip)

is there anything I'm missing?

Have you copied the latest support v4 library to your custom libs folder and are you sure it is really the latest?
 

sanjibnanda

Active Member
Licensed User
Longtime User
hey!
question 2 ) resolved as
done.jpg

B4X:
    If List.Get(k-1) = k Then
      pop.AddMenuItem(k, "Question# " & k, GetDrawable("image_1"))
    Else
      pop.AddMenuItem(k, "Question# " & k, GetDrawable("image_2"))
    End If

Please help me to resolve to get the pop up some thing like this with 100%x

need.jpg


thanks
 

corwin42

Expert
Licensed User
Longtime User
hey! this forum never took so much time to reply either affirmatively or otherwise.
i am stuck on the project, if this is not possible ...plz let me know so that i could find some other way round.
regards,
sanjib

The PopupMenu object uses the standard Android PopupMenu class. There is no way to control the width ob the menu to set it to 100%x. The width of the PopupMenu is calculated from the size of its contents.
 

corwin42

Expert
Licensed User
Longtime User
hello corwin42
how can i display multilevel navigation in NavDrawer just like this

navigation_drawer_holo_dark_light.png


your help will be appreciated ....
regards

This question is not really related to this library nor the AHNavigationDrawer library. It may be possible to use something like the Ultimate ListView Library.

If you need further help on this please start a new thread in the questions forum.
 

corwin42

Expert
Licensed User
Longtime User
You have to create your own theme with a modified style for the PopupMenu. I haven't done it manually by myself but have a look at this link. The solution there should work.

You can even use the Action Bar Style Generator to create a complete theme for the ActionBar which will change the appearance of the PopupMenu, too.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
I initialize PopupMenu in ULV_DBQ_CellLongClick each time in order to have MenuItem Title based on data in ULV Row. I noticed, that icon is shown only for the first time. Then Menu is shown and works correctly, but icon is not displayed.
 

corwin42

Expert
Licensed User
Longtime User
I initialize PopupMenu in ULV_DBQ_CellLongClick each time in order to have MenuItem Title based on data in ULV Row. I noticed, that icon is shown only for the first time. Then Menu is shown and works correctly, but icon is not displayed.

This is indeed a bug which occurs if the PopupMenu is initialized again. Try to Dim it again, too not just initialize. This should fix the problem.
 

Myr0n

Active Member
Licensed User
Longtime User
Hi
How can show permanently the action overflow menu on the action bar with this library?
I would like to do that, because my device has a physical menu button but I have other devices that do not and I would like that my app, show as same is possible in any device.

Thank you
 

corwin42

Expert
Licensed User
Longtime User
Hi
How can show permanently the action overflow menu on the action bar with this library?
You can't. This library does not control the overflow menu.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
Hi corwin42,

Could you remove the messages in the LOG like
"Set Icon"
"Set Icons visible"
"Done"
from the PopupMenu class.

Thank you.
 

NeverGiveUp2

Member
Licensed User
Longtime User
Hi Corwin42,

thank's for your good work here in the community. I start with the actionbar in last week and find
your StdActionbar-lib. Is it possible to change the hook-icon on the left side in another icon. I tried some different
code, but the icon is every time only the hook-icon. I would like to change this icon. Is this
possible, or do you can modify your lib.
 

NeverGiveUp2

Member
Licensed User
Longtime User
The answer of my question is:

You have to generate your own theme!

B4X:
<resources>

  <style name="Theme.Meal4up" parent="@android:style/Theme.Holo.Light">
  
  <!-- This is the icon for close the menu. Original-Icon is "ic_cab_done_holo_light" -->
       <item name="android:actionModeCloseDrawable">@drawable/ic_action_back</item>
  
  
  </style>
</resource>

Here an importand information for custom xml-theme-files. The file name is not importand for the b4a-manifest-file.

You have to use the name inside the File.

Example: Filename: theme.xml

inside File:

<style name="Theme.Meal4up" parent="@android:style/Theme.Holo.Light">

Line in the b4a-Manifest-Editor:

SetApplicationAttribute(android:theme, "@style/Theme.Meal4up")

Hope it will helpfull.
 
Top