8

私はAndroidのGWTのトースト通知に似たコンポーネントを探していました(私は十分に長い間グーグルで検索し、似たようなものがあるExt-GWTがあることを知っていますが、外部ライブラリを避けたいです)。NotificationMoleは私が探しているコンポーネントであり、このコンポーネントはGWT2.1で利用できるようです。ただし、アプリに表示しようとすると、表示されません。誰かがこのコンポーネントを使用しましたか?これが私がそれをどのように使うかの例です:

NotificationMole nm = new NotificationMole();
nm.setAnimationDuration(2000);
nm.setTitle("Title");
nm.setHeight("100px");
nm.setWidth("200px");
nm.setMessage("Test message to be shown in mole");
nm.show();
4

2 に答える 2

11

NotificationMoleは、表示する前にDOMにアタッチする必要があります。

HasWidgets panel; // This can be any panel that accepts children.
NotificationMole nm = new NotificatioMole();
panel.add(nm);
// Setup the NotificationMole...
nm.show();
于 2011-02-08T17:55:56.163 に答える
0
private void tellUser(String what) 
{
    PopupPanel pop = new PopupPanel(true);
    pop.setWidget(new Label(what));


    final PopupPanel p = pop;

    RootPanel.get().add(pop);

    pop.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
          public void setPosition(int offsetWidth, int offsetHeight) {
            int left = (Window.getClientWidth() - offsetWidth) / 2;
            int top = (Window.getClientHeight() - offsetHeight) / 2;
            p.setPopupPosition(left, top);
          }
        });

    new Timer() {
      @Override
      public void run() 
      {
        System.out.println("timer repeated");
        RootPanel.get().remove(p);
        this.cancel();
      }
    }.scheduleRepeating(2000);
}
于 2013-06-29T16:36:56.927 に答える