Reputation: 477
I have a codename one application that uses an Icon in the title positioned at right. This icon signalizes existence of notifications didn't read from the current user. Also can be used to launch Notifications Form where the user can read, reply and send Notifications from/to other users.
I used in my code Toolbar.setGlobalToolbar(true);
in init()
method of the java code that starts my app.
And, used the following call to put the notification's Icon at right inside title's bar:
this.notifCommand =
toolbar.addMaterialCommandToRightBar(
"",
FontImage.MATERIAL_NOTIFICATIONS_NONE,
MY_ICON__SIZE,
(ActionEvent e) -> {
showIwNotificationForm();
}
);
This command above was written inside a FormBase
class that is the parent of all Forms of my app.
This is working fine. I have the notification icon in all title bar of my app and the user can launch the Notifications Form, etc... The app makes the device vibrate when the user has notifications, etc, ...
But, I have the necessity of dynamically exchange the color of Notification Icon depending on its priority or even exchange the Notification Icon itself.
I have difficult to do that. I tried several approaches without good results.
How can I do that?
Upvotes: 1
Views: 29
Reputation: 52760
You can invoke this at any point after adding the command:
Button b = form.getToolbar().findCommandComponent(notifCommand);
Once you have that you have a button where you can control the icon used completely. You can replace it with every image including an image you drew dynamically and you can set its UIID...
Upvotes: 0