Android Example AppCompat with ToolBar - minimal example

Discussion in 'Tutorials & Examples' started by Erel, May 24, 2017.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    appcompat.gif



    The project attached uses the powerful AppCompat library to replace the built-in ActionBar with a more robust ToolBar.

    The NavigationItemClick event is raised when the icon is clicked.

    You can set ToolbarHelper.ShowUpIndicator = True to show an up arrow instead. It will raise the same event.

    [​IMG]

    You can change the toolbar color in the manifest editor.

    Sliding side menu + dynamic menu items: https://www.b4x.com/android/forum/threads/appcompat-with-toolbar-minimal-example.79896/#post-509530

    [​IMG]

    Example based on B4ADrawer: https://www.b4x.com/android/forum/threads/class-b4adrawer-sliding-drawer.97828/#post-616518

    [​IMG]
     

    Attached Files:

    Last edited: Nov 17, 2019 at 6:17 AM
  2. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

  3. vfafou

    vfafou Active Member Licensed User

    Hello!
    When I try to compile, I'm getting the following error:
    Code:
    B4A version: 7.01
    Parsing code.    (
    0.00s)
    Compiling code.    (
    0.15s)
    Compiling layouts code.    (
    0.02s)
    Organizing libraries.    (
    0.00s)
    Generating R 
    file.    Error
    C:\Users\VF\Desktop\AppCompatWithSlidingMenu\AppCompat\Objects\bin\extra\res3\res\values-v24\values-v24.xml:
    3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
    C:\Users\VF\Desktop\AppCompatWithSlidingMenu\AppCompat\Objects\bin\extra\res3\res\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
    Any suggestion?

    Thank you in advance!
     
  4. DonManfred

    DonManfred Expert Licensed User

    I guess you are using an Android.jar from Api below 24...

    Use a more recent android.jar (25 as of today) and set it under Tools->Configure Paths
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    vfafou and lemonisdead like this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    A new example that shows how to update or add menu items at runtime.

    [​IMG]
     

    Attached Files:

    Last edited: Jun 8, 2017
  7. Peter Simpson

    Peter Simpson Expert Licensed User

    Works perfect as usual, thank you...
     
    Erel likes this.
  8. Ivan Fernando Paz

    Ivan Fernando Paz Member Licensed User

    That's great
     
  9. little3399

    little3399 Active Member Licensed User

    AppCompatWithDynamicMenuAndBadge DEMO program, can't seem to run? Are there any requirements for the Android version?

    because it run once , it will go back to the os ...
     
  10. little3399

    little3399 Active Member Licensed User

  11. woniol

    woniol Active Member Licensed User

  12. little3399

    little3399 Active Member Licensed User

    @woniol ,TKS , it work fine !
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Now with a more colorful popup menu:

    [​IMG]

    The color is set in the manifest editor:
    Code:
    <style name="ToolbarMenu" parent="Base.ThemeOverlay.AppCompat.ActionBar">
        <item name=
    "android:textColorPrimary">#fff</item>
        <item name=
    "android:colorBackground">#0098FF</item>
       </style>
    And is set with this code:
    Code:
    Dim jo As JavaObject = ACToolBarLight1
    Dim xl As XmlLayoutBuilder
    jo.RunMethod(
    "setPopupTheme"Array(xl.GetResourceId("style""ToolbarMenu")))
     

    Attached Files:

  14. Cassie

    Cassie Member Licensed User

    Hi Guys,

    any idea what could this error be "invalid resource directory name: C:\Users\Admin\Documents\Tutorials And Samples\B4a Samples\AppCompatWithDynamicMenuAndBadge\AppCompat\Objects\bin\extra\res2\res/values-b+sr+Latn"

    Thanks
     
  15. DonManfred

    DonManfred Expert Licensed User

    Which B4A Version are you using?
     
  16. Erel

    Erel Administrator Staff Member Licensed User

  17. Cassie

    Cassie Member Licensed User

  18. Cassie

    Cassie Member Licensed User

    I'm using the latest version of B4A Version 7.01.
     
  19. lemonisdead

    lemonisdead Well-Known Member Licensed User

    DonManfred likes this.
  20. DonManfred

    DonManfred Expert Licensed User

    Talking about B4A you are right. But Erel said that the issue is related to the installed Build-Tools. It should be a NEWER one than you are using.

    [​IMG]
    Install the newer 25.0.3.
    DEINSTALL all versions <25
     
    lemonisdead likes this.
Thread Status:
Not open for further replies.
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