0

GWTアプリ内でGXTのInfoクラスを使用して、メッセージまたは通知を表示しています。メッセージを少し粘着性のあるものにするために、私は独自のバージョンのInfoクラスを実装しました。InfoConfigインスタンスを作成し、ミリ秒数を設定しました。config.display(int milliseconds);

hide()問題は、情報を「スティッキー」にする必要がない場合があるため、他のことを行うときに情報を非表示にする必要があることです。メソッドを呼び出そうとしましたが、機能しません。

Infoクラスの私の実装:

public class StickyInfo extends Info {

    private static StickyInfo info = new StickyInfo();

    public StickyInfo() {
        super();
    }

    @Override
    protected void onShowInfo() {
        super.onShowInfo();
    }

    /**
     * Show the message with a title for 20sec (default duration)
     * 
     * @param title
     *            the title of the message.
     * @param message
     *            the message to display.
     */
    public void show(String title, String message) {
        show(title, message, 20000); // for 20sec
    }

    /**
     * Show the message with no title for 20sec (default duration)
     * 
     * @param message
     *            the message to display.
     */
    public void show(String message) {
        show(null, message, 20000); // for 20sec
    }

    /**
     * Show the message for the specified number of milliseconds.
     * 
     * @param title
     *            the title of the message.
     * @param message
     *            the message to display.
     * @param milliseconds
     *            the number of milliseconds to display the message.
     */
    public void show(String title, String message, int milliseconds) {
        // Configuration
        InfoConfig config = new DefaultInfoConfig(title, message);
        config.setDisplay(milliseconds);
        // Formatting
        info.setStyleName("background-color:#f9ff4f;text-align:center;"
                + "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
        info.show(config);

        // Position
        // Point p = info.position();
        // p.setY(p.getY() + 400);
        // p.setX(0);
        info.setPagePosition(info.position().getX(), 55);
    }

    /**
     * Show the message in the given position for the number of milliseconds.
     * 
     * @param title
     *            the title of the message.
     * @param message
     *            the message to display.
     * @param milliseconds
     *            the number of milliseconds to display the message.
     */
    public void show(String title, String message, int milliseconds, int pX,
            int pY) {
        // Configuration
        InfoConfig config = new DefaultInfoConfig(title, message);
        config.setDisplay(milliseconds);
        // Formatting
        info.setStyleName("background-color:#f9ff4f;text-align:center;"
                + "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
        info.show(config);

        // Position
        // Point p = info.position();
        // p.setY(p.getY() + 400);
        // p.setX(0);
        info.setPagePosition(pX, pY);
    }

ポインタはありますか?ありがとう。

4

2 に答える 2

2

@Override Hide()メソッドを試してください...。

于 2013-03-27T14:07:04.900 に答える
0

user2043260が述べたように、私はのようにメソッドをオーバーライドしようとしましたhide()

@Override
public void hide() {
   if (info.getParent != null) {
      info.removeFromParent();
   }
} 

そしてそれはうまくいきます:)!念押し有難う ;)

于 2013-03-28T00:08:06.963 に答える