📄 consumelist.java
字号:
package consume;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.rms.*;
import java.util.Date;
public class ConsumeList extends List implements CommandListener {
/** Constructor */
public ConsumeList() {
super("数据列表",List.IMPLICIT);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Component initialization*/
private void jbInit() throws Exception {
// Set up this Displayable to listen to command events
setCommandListener(this);
// add the Exit command
addCommand(new Command("返回", Command.BACK , 1));
RecordStore rs;
try {
rs = RecordStore.openRecordStore("consume", true);
RecordEnumeration enum = rs.enumerateRecords(null, null, false);
while (enum.hasNextElement()) {
try {
byte[] data = enum.nextRecord();
DataInputStream is = new DataInputStream(new ByteArrayInputStream(
data));
ConsumeData record = new ConsumeData();
record.date = new Date();
record.date.setTime(is.readLong());
record.Num = is.readFloat();
is.close();
this.append(String.valueOf(record.Num),null);
// this.append(String.valueOf(record.Num)+" "+String.valueOf(record.date),null);
}
catch (InvalidRecordIDException ex) {
// Ignore deleted record
}
}
enum.destroy();
rs.closeRecordStore();
}
catch (IOException ie) {}
catch (RecordStoreException e2) {
}
}
/**Handle command events*/
public void commandAction(Command command, Displayable displayable) {
/** @todo Add command handling code */
if (command.getCommandType() == Command.BACK) {
ConsumeMIDlet.instance.backmain();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -