Android Example AppCompat with ToolBar - minimal example

Status
Not open for further replies.
In most cases AppCompat is no longer needed and will only make things more complicated.
B4XPages example with dynamic menu: https://www.b4x.com/android/forum/threads/b4x-menu-badges.133301/

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.

SS-2017-05-24_12.20.07.png


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

SS-2017-06-08_17.06.06.png


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

b4adrawer.gif



Edit: depending on your Android SDK version, you might get this error:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;

The solution is to add this line in the main activity:
B4X:
#AdditionalJar: androidx.arch.core:core-runtime
 

Attachments

  • upload_2017-5-24_12-18-26.png
    upload_2017-5-24_12-18-26.png
    7.3 KB · Views: 3,936
  • AppCompatExample.zip
    9.9 KB · Views: 3,325
Last edited:
Status
Not open for further replies.
Top