⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmsmidlet.java

📁 手机上的addressbook
💻 JAVA
字号:
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();
		}

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -