Skip to content

Instantly share code, notes, and snippets.

@codenameone
Forked from shannah/BasicUsage.java
Last active July 8, 2020 09:57
Show Gist options
  • Save codenameone/4584f342783169899b34 to your computer and use it in GitHub Desktop.
Save codenameone/4584f342783169899b34 to your computer and use it in GitHub Desktop.
Form hi = new Form("ToastBarDemo", BoxLayout.y());
Button basic = new Button("Basic");
Button progress = new Button("Progress");
Button expires = new Button("Expires");
Button delayed = new Button("Delayed");
hi.add(basic).add(progress).add(expires).add(delayed);
basic.addActionListener(e -> {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.show();
//... Some time later you must clear the status
// status.clear();
});
progress.addActionListener(e -> {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.setShowProgressIndicator(true);
status.show();
// ... Some time later you must clear it
});
expires.addActionListener(e -> {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.setExpires(3000); // only show the status for 3 seconds, then have it automatically clear
status.show();
});
delayed.addActionListener(e -> {
ToastBar.Status status = ToastBar.getInstance().createStatus();
status.setMessage("Hello world");
status.showDelayed(300); // Wait 300 ms to show the status
// ... Some time later, clear the status... this may be before it shows at all
});
hi.show();
@codenameone
Copy link
Author

Sample usage of ToastBar.

From the Codename One project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment