Notifications
Creation of a Notification
Content Needed to Create a Notification
A Simple Example
import totalcross.notification.Notification;
import totalcross.notification.NotificationManager;
import totalcross.sys.Settings;
import totalcross.ui.Button;
import totalcross.ui.Edit;
import totalcross.ui.MainWindow;
public class HelloWorld extends MainWindow {
private Button btnHello;
public HelloWorld(){
super("", NO_BORDER);
Settings.uiAdjustmentsBasedOnFontHeight = true;
setUIStyle(Settings.Material);
}
public void initUI() {
Edit title = new Edit("Title");
title.caption = "Title";
add(title, LEFT+150, TOP+100, FILL-150, PREFERRED);
Edit text = new Edit("Text");
text.caption = "Text";
add(text, LEFT+150, AFTER+50, FILL-150, PREFERRED);
btnHello = new Button("Notify!");
btnHello.addPressListener(
(e) -> {
Notification.Builder builder = new Notification.Builder();
Notification notification = builder
.title(title.getText())
.text(text.getText())
.build();
NotificationManager.getInstance().notify(notification);
});
add(btnHello, CENTER, AFTER+150, PARENTSIZE+38, PARENTSIZE+8);
}
}References
Last updated
Was this helpful?