📄 listrecord.java
字号:
/* * 记录列表 */package PhoneBook;import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;import javax.microedition.rms.*;public class ListRecord extends List implements CommandListener { private Displayable dis; private MIDlet mid; private RecordStore rs = null; private RecordEnumeration re = null; private static final Command lookCommand = new Command("查看", Command.OK, 1); private static final Command backCommand = new Command("返回", Command.BACK, 2); //父屏幕的参数是dis public ListRecord(String title, int listType, Displayable dis, MIDlet mid, RecordStore rs) { super(title, listType); this.dis = dis; this.mid = mid; this.rs = rs; this.addCommand(backCommand); this.addCommand(lookCommand); this.setCommandListener(this); SortComparator sortCom = new SortComparator(); if (rs != null) { try { //Image icon = Image.createImage("/txt.png"); //按照名字的字符串大小排序 re = rs.enumerateRecords(null, sortCom, true); //添加列表项 while (re.hasNextElement()) { //分解数据库记录数据 BookAccount account = BookAccount.deserialize(re.nextRecord()); //把名字添加到列表中 int index = this.append(account.getUserName(), null); } } catch (Exception e) { } finally { if (re != null) { re.destroy(); } } } } public void commandAction(Command c, Displayable d) { if (c == backCommand) { Display.getDisplay(mid).setCurrent(dis); } if (c == lookCommand) { //进入记录编辑界面 EditDetailInfo edInfo = new EditDetailInfo("查看和修改记录", this, mid, rs, this.getString(this.getSelectedIndex())); Display.getDisplay(mid).setCurrent(edInfo); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -