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:

Cassie

Member
Licensed User
Longtime 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.

buildtools001.png

Install the newer 25.0.3.
DEINSTALL all versions <25

Follow your information and now it is working.. Thanks guys..
 

fishwolf

Well-Known Member
Licensed User
Longtime User
A new example that shows how to update or add menu items at runtime.

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

i have try to set
B4X:
        <item name="android:colorBackground">#4CFF00</item>
or 
        <item name="android:textColorPrimary">#4CFF00</item>
but toolbar menu color don't change
work fine if change
B4X:
 <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#4CFF00</item>
 

so27

Active Member
Licensed User
Longtime User
Why work created apps with me only from Android 5? As soon as I install the app on Android 4.x, it crashes directly.

2017-09-22_07h42_56.png
 

Drago Bratko

Active Member
Licensed User
Longtime User
I have issue with running it. :-(
Compile&Run is finished well, and no log entries loged in IDE. Then, apk is transfered well to B4A-Bridge, and is asking me to allow installation. And after that I got following screen which says that "App is not installed, as it's assumed that package is damaged". Any ideas ?
I have latest Android SDK build tools and latest jdk version.
 

Attachments

  • Screenshot_20171012-094004.png
    Screenshot_20171012-094004.png
    23.5 KB · Views: 699

Ramon Bustamante

Member
Licensed User
Hi guys, I tried to execute AppCompat and I obtain the errors:
Organizing libraries. Error
Maven artifact not found: com.android.support/appcompat-v7
 

Attachments

  • Error.png
    Error.png
    101.5 KB · Views: 618

M.LAZ

Active Member
Licensed User
Longtime User
how to display the slide menu in the right side ? i try to change it by
B4X:
sm.Mode = sm.RIGHT ' LEFT
but the hamburger icon still in the left side...
 

David Elkington

Active Member
Licensed User
Longtime User
This looks just what I need. I ran the demo fine, but when I tried to plug this onto my main menu on my app, it compiles ok, but it gives the following error, any ideas?

java.lang.RuntimeException: java.lang.ClassCastException: b4a.riskassessment.mainmenu cannot be cast to android.support.v7.app.AppCompatActivity
 
Status
Not open for further replies.
Top