moto List一个有趣的问题

/*
 *
 * Copyright © 2007 Sun Microsystems, Inc. All rights reserved.
 * Use is subject to license terms.
 */
package list;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;


/**
 * The MIDlet demonstrates the different types of list supported by MIDP-2.0:
 *      EXCLUSIVE - a choice having exactly one element selected at time.
 *      IMPLICIT  - a choice in which the currently focused element is
 *                  selected when a Command is initiated.
 *      MULTIPLE  - a choice that can have arbitrary number of elements
 *                  selected at a time.
 *
 * @version 2.0
 */
public class ListDemo extends MIDlet implements CommandListener {
    private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
    private static final Command CMD_BACK = new Command("Back", Command.BACK, 1);
    private Display display;
    private List mainList;
    private List exclusiveList;
    private List implicitList;
    private List multipleList;
    private boolean firstTime;

    public ListDemo() {
        display = Display.getDisplay(this);

        // these are the strings for the choices.
        String[] stringArray = {
    "Rowboating(420/0.5hour)",           
    "Spin and weave(400/0.5hour)",               
    "Playing squash(360/0.5hour)",
    "Judo(300/0.5hour)",
    "Fencing(300/0.5hour)",
    "Swimming(273/0.5hour)",
    "Boxing(225/0.5hour)",
    "Rope Skipping(224/0.5hour)",
    "Sit-ups(216/0.5hour)",
    "Playing football(210/0.5hour)",
    "Playing basketball(200/0.5hour)",
    "Aerobic(190/0.5hour)",
    "Skiing(177/0.5hour)",
    "Playing tennis(176/0.5hour)",
    "Running(176/0.5hour)",
    "Weight lifting(165/0.5hour)",
    "Hiking(150/0.5hour)",
    "Mark time machine(150/0.5hour)",
    "Stepping(141/0.5hour)",
    "Horse riding(138/0.5hour)",
    "Playing badminton(135/0.5hour)",
    "Playing snooker(135/0.5hour)",
    "Aerobic exercise(126/0.5hour)",//
    "Playing table tennis(120/0.5hour)",
    "Take a sharp walk(114/0.5hour)",
    "Jogging(112/0.5hour)",
    "Dancing(102/0.5hour)",
    "Cycling(92/0.5hour)",
    "Playing volleyball(90/0.5hour)",
    "Playing bowling(90/0.5hour)",
    "Take a walk(66/0.5hour)",
    "Golfing(43/0.5hour)",
                                  };

        // the string elements will have no images
        Image[] imageArray = null;

        /*
         * create samples of the supported types:
         *      "Exclusive", "Implicit" and  "Multiple"
         */
        exclusiveList = new List("Exclusive", Choice.EXCLUSIVE, stringArray, imageArray);
        exclusiveList.addCommand(CMD_BACK);
        exclusiveList.addCommand(CMD_EXIT);
        exclusiveList.setCommandListener(this);

        implicitList = new List("Implicit", Choice.IMPLICIT, stringArray, imageArray);
        implicitList.addCommand(CMD_BACK);
        implicitList.addCommand(CMD_EXIT);
        implicitList.setCommandListener(this);

        multipleList = new List("Multiple", Choice.MULTIPLE, stringArray, imageArray);
        multipleList.addCommand(CMD_BACK);
        multipleList.addCommand(CMD_EXIT);
        multipleList.setCommandListener(this);

        firstTime = true;
    }

    protected void startApp() {
        if (firstTime) {
            // these are the images and strings for the choices.
            Image[] imageArray = null;

            try {
                // load the duke image to place in the image array
                Image icon = Image.createImage("/midp/uidemo/Icon.png");

                // these are the images and strings for the choices.
                imageArray = new Image[] { icon, icon, icon };
            } catch (java.io.IOException err) {
                // ignore the image loading failure the application can recover.
            }

            String[] stringArray = { "Exclusive", "Implicit", "Multiple" };
            mainList = new List("Choose type", Choice.IMPLICIT, stringArray, imageArray);
            mainList.addCommand(CMD_EXIT);
            mainList.setCommandListener(this);
            display.setCurrent(mainList);
            firstTime = false;
        }
    }

    protected void destroyApp(boolean unconditional) {
    }

    protected void pauseApp() {
    }

    public void commandAction(Command c, Displayable d) {
        if (d.equals(mainList)) {
            // in the main list
            if (c == List.SELECT_COMMAND) {
                if (d.equals(mainList)) {
                    switch (((List)d).getSelectedIndex()) {
                    case 0:
                        display.setCurrent(exclusiveList);

                        break;

                    case 1:
                        display.setCurrent(implicitList);

                        break;

                    case 2:
                        display.setCurrent(multipleList);

                        break;
                    }
                }
            }
        } else {
            // in one of the sub-lists
            if (c == CMD_BACK) {
                display.setCurrent(mainList);
            }
        }

        if (c == CMD_EXIT) {
            destroyApp(false);
            notifyDestroyed();
        }
    }
}
这个程序用moto EM30测试时  选MULTIPLE时会发现最后一行只有一半。
还有一个问题 是 如果程序运行时 中断返回到待机画面,修改话机的时间(时间如果调为将来的某个时间)在中断返回是没有问题的,如果修改话机的时间(时间调为比当前手机中时间更早的时间)则会导致程序返回时有异常现象(比如屏幕停滞,无法响应按键事件)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值