MIDP2.0中Alert的新特性[3]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

            done();
        }

        private Alert _alert;
        private int _counter;
        private boolean _done;
        private Gauge _gauge;
    }

    // An alert test that displays a continuously
    // running gauge before automatically timing out.

    public class BusyAlert extends AlertRunner
    {
        public BusyAlert(String title)
        {
            super(title);
        }

        public Alert doAlert()
        {
            _gauge = new Gauge(null, false, Gauge.INDEFINITE,
                    Gauge.CONTINUOUS_RUNNING);

            _alert = new Alert(getTitle());
            _alert.setString("Runs for 5 seconds and "
                    + "times out automatically");
            _alert.setIndicator(_gauge);
            _alert.setTimeout(FIVE_SECONDS);

            showAlert(_alert);

            return _alert;
        }

        private Alert _alert;
        private Gauge _gauge;
    }

    // Standard MIDlet code. Displays a list of
    // available alert tests and runs the test once
    // it's been chosen.

    private Display display;

    public static final Command exitCommand = new Command("Exit", Command.EXIT,
            1);

    public AlertTest()
    {
    }

    public void commandAction(Command c, Displayable d)
    {
        if (c == exitCommand)
        {
            exitMIDlet();
        } else if (c == List.SELECT_COMMAND)
        {
            int index = _alertList.getSelectedIndex();
            _alertRunners[index].doAlert();
        }
    }

    protected void destroyApp(boolean unconditional)
            throws MIDletStateChangeException
    {
        exitMIDlet();
    }

    public void exitMIDlet()
    {
        notifyDestroyed();
    }

    public Display getDisplay()
    {
        return display;
    }

    protected void initMIDlet()
    {

        // The list of alert tests....

        _alertRunners = new AlertRunner[] { new TimedAlert("Timed alert"),
                new ModalAlert("Modal alert"),
                new ProgressAlert("Progress alert"),
                new BusyAlert("Busy alert") };

本文关键:MIDP2.0中Alert的新特性
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top