手机通讯录工具

源代码在线查看: rmsmidlet.java

软件大小: 490 K
上传用户: mengcong18
关键词: 手机通讯
下载地址: 免注册下载 普通下载 VIP

相关代码

				package chapter4.addressbook;
				
				import javax.microedition.lcdui.*;
				import javax.microedition.midlet.MIDlet;
				
				public class RMSMIDlet extends MIDlet implements CommandListener {
				
					Operation oper = new Operation();
					private String[] elements = { "增加记录", "查询记录", "修改记录", "删除记录" };
					private List list = null;
					private Command select = new Command("选择", Command.OK, 1);
					private Display display = null;
					private Form addform = new Form("增加记录");
					private TextField addname = new TextField("姓名:", "", 8, TextField.ANY);
					private TextField addphone = new TextField("电话:", "", 11, TextField.NUMERIC);
					private Form selectform = new Form("查询记录");
					private TextField selectnamet = new TextField("姓名:", "", 8, TextField.ANY);
					private Form updateform = new Form("修改记录");
					private Command ok = new Command("确定", Command.OK, 1);
					private Command back = new Command("返回", Command.BACK, 1);
				
					public RMSMIDlet() {
						if (display == null) {
							display = Display.getDisplay(this);
						}
						list.addCommand(select);
						list.setCommandListener(this);
					}
				
					protected void destroyApp(boolean arg0) {
				
					}
				
					protected void pauseApp() {
				
					}
				
					protected void startApp() {
						Image img1 = null;
						Image img2 = null;
						try {
							img1 = Image.createImage("/img1.png");
							img2 = Image.createImage("/img2.png");
						} catch (Exception e) {
						}
						Image[] images = { img1, img1, img2, img2 };
						list = new List("通信录", List.IMPLICIT, elements, images);
					}
				
					public void commandAction(Command cmd, Displayable displayable) {
						int selectedIndex = list.getSelectedIndex();
						if (cmd == select) {
							if (selectedIndex == 0) {
								addform.append(addname);
								addform.append(addphone);
								addform.addCommand(ok);
								addform.addCommand(back);
								addform.setCommandListener(this);
								display.setCurrent(addform);
								String name = addname.getString();
								String phone = addphone.getString();
								oper.addRecord(name, phone);
				
							}
				/*			if (selectedIndex == 1) {
							}
							if (selectedIndex == 2) {
							}
							if (selectedIndex == 3) {
							}*/
				
						} else {
							destroyApp(false);
							notifyDestroyed();
						}
				
					}
				
				}
							

相关资源