Android Question change Activity menu icon after added

John Decowski

Member
Licensed User
Longtime User
Hi i have created a menu icon using Activity.AddMenuItem3 I would like to know how to modify the icon created from this method.
CODE:
Activity.AddMenuItem3("Notify", "Notify",LoadBitmap(File.DirAssets, "notify9.png"),True)

Thanks in advance.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I'm not aware of any way to do this in B4A code, but you might be able to do it using Java. Try Googling something like "Android change activity menu item at runtime" & see what you can find.

- Colin.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ALBRECHT

Active Member
Licensed User
Hello,

When i try to use the example AppCompat with ToolBar - minimal example :
from : https://www.b4x.com/android/forum/attachments/appcompatexample-zip.85601/

with : B4X 3.9 / AppCompat : 3.52 / SlidingMenuWrapper : 1.10 (the Android SDK BuildTools is: 27.0.1)

I get the Error at Activity.LoadLayout("1") :
B4X:
Copying updated assets files (4)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
[COLOR=rgb(184, 49, 47)]Error occurred on line: 33 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.example.main._activity_create(main.java:398)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:104)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
    ... 18 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/Toolbar;
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:453)
    at java.lang.Class.forName(Class.java:378)
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:624)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:611)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:366)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.initializeGlobals(main.java:320)
    at b4a.example.main.afterFirstLayout(main.java:101)
    ... 9 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/data/app/b4a.example-ndYqVCN7PQdKgUNjNbWR_g==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-ndYqVCN7PQdKgUNjNbWR_g==/lib/x86_64, /system/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 20 more[/COLOR]
** Activity (main) Resume **

Kind Regards
Michel
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ALBRECHT

Active Member
Licensed User
sorry, i m wrong with the version of the Core: i m using Version 9.80 (not 3.80)
Great, all is ok with : AppCompat 4.00
Thanks
 
Last edited:
Upvote 0
Top