J2ME手机游戏设计案例源代码-TestList

上传人:平*** 文档编号:11196746 上传时间:2017-10-12 格式:DOC 页数:4 大小:37.67KB
返回 下载 相关 举报
J2ME手机游戏设计案例源代码-TestList_第1页
第1页 / 共4页
J2ME手机游戏设计案例源代码-TestList_第2页
第2页 / 共4页
J2ME手机游戏设计案例源代码-TestList_第3页
第3页 / 共4页
J2ME手机游戏设计案例源代码-TestList_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《J2ME手机游戏设计案例源代码-TestList》由会员分享,可在线阅读,更多相关《J2ME手机游戏设计案例源代码-TestList(4页珍藏版)》请在金锄头文库上搜索。

1、*TestListMID/* To change this template, choose Tools | Templates* and open the template in the editor.*/import javax.microedition.lcdui.Choice;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcd

2、ui.Displayable;import javax.microedition.lcdui.Image;import javax.microedition.lcdui.List;import javax.microedition.midlet.*;/* author Administrator*/public class TestListMID extends MIDlet implements CommandListener /这里注意如何使用/CommandListener 这个接口private final static Command CMD_EXIT = new Command(E

3、xit, Command.EXIT, 1);private final static 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;Image imageArray= null; public TestListMID() display

4、 = Display.getDisplay(this);String stringArray = 选项 A,选项 B,选项 C,选项 D; /待传入进行初始化的 String 数组,即 Choice 选项的文字部分。/这里只是为 Image数组进行初始化。 exclusiveList = new List(Exclusive, Choice.EXCLUSIVE, stringArray,imageArray);exclusiveList.addCommand(CMD_BACK);exclusiveList.addCommand(CMD_EXIT);exclusiveList.setComman

5、dListener(this);/ExlcusiveList 的声明implicitList = new List(Implicit, Choice.IMPLICIT, stringArray, imageArray);implicitList.addCommand(CMD_BACK);implicitList.addCommand(CMD_EXIT);implicitList.setCommandListener(this);/ImplicitList 的声明multipleList = new List(Multiple, Choice.MULTIPLE, stringArray, ima

6、geArray);multipleList.addCommand(CMD_BACK);multipleList.addCommand(CMD_EXIT);multipleList.setCommandListener(this);/MutipleList 的声明firstTime = true; protected void startApp() if(firstTime) imageArray = null;try Image icon = Image.createImage(/Icon.png);/注意!这里的路径是相对路径,请大家千万注意这里的细节问题imageArray = new I

7、mage 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(t

8、his);display.setCurrent(mainList);firstTime = false; protected void pauseApp() protected void destroyApp(boolean unconditional) public void commandAction(Command c, Displayable d) /注意这里是如何实现 CommandListener 这个接口的!if (d.equals(mainList) 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-listsif (c = CMD_BACK) display.setCurrent(mainList); if (c = CMD_EXIT) destroyApp(false);notifyDestroyed();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号