Notifications

Notifications

Notifications sind kleine Dialoge, welche auf der View erscheinen, um den Benutzer etwas mitzuteilen.

Erstellen einer einfachen Notification:

Notification.show("Hello!");

Ergebnis: Am linken unteren Bildschirmrand, taucht eine kleine Notification auf.

Erstellen und Konfigurieren einer Notification:

final Notification myNotification = new Notification(); myNotification.setDuration(2000); // Zeige die Notification für 2 Sekunden myNotification.setText("Hello!"); // Setze den Text auf "Hello!" myNotification.setPosition(Position.TOP_START); // Die Notification soll von links oben erscheinen myNotification.addThemeVariants(NotificationVariant.LUMO_SUCCESS); // Die Notification soll eine SUCCESS Nachricht sein // Zeige die Notification an myNotification.open();

Ergebnis:



Notifications sind nicht nur auf einen Text eingeschränkt, sondern können auch ganze Views und Layouts beinhalten.

Beispiel:

final VerticalLayout layout = new VerticalLayout(); layout.add(new Button("Test Button")); layout.add(new Label("You can add more than just text!")); final Notification myNotification = new Notification(layout); myNotification.open();

Ergebnis:





XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.