📄 editscreen.java
字号:
import javax.microedition.lcdui.*;
import java.io.IOException;
public class EditScreen extends Form implements CommandListener
{
private Command selectCommand, commitCommand, backCommand;
private ChoiceGroup recStore;
private String[] table;
private TextField name, phone;
private String stname, stphone, recordno;
private int selection;
public EditScreen()
{
super("Edit Screen");
try
{
selectCommand = new Command("Select record", Command.SCREEN, 0);
commitCommand = (new Command("Commit", Command.SCREEN, 1));
backCommand = (new Command("Back", Command.BACK, 1));
addCommand(selectCommand);
addCommand(commitCommand);
addCommand(backCommand);
name = new TextField("Name: ", "", 10, TextField.ANY);
phone = new TextField("number: ", "", 10, TextField.ANY);
setCommandListener(this);
table = TelephoneListMIDlet.pd.readRecordStore();
recStore = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE, table, null);
append("select the record you want to edit by using the up an down arrows and then pressing SELECT");
append(recStore);
append(
"press menu and 'Select Record', edit the record then press menu and 'Commit'");
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void commandAction(Command c, Displayable d)
{
if (c == selectCommand)
{
selection = recStore.getSelectedIndex();
name.setString(TelephoneListMIDlet.pd.getName(table[selection]));
phone.setString(TelephoneListMIDlet.pd.getTelno(table[selection]));
recordno = TelephoneListMIDlet.pd.getRecno(table[selection]);
append(name);
append(phone);
}
else if (c == commitCommand)
{
stname = name.getString();
stphone = phone.getString();
byte[] rec = (stname + ";" + stphone).getBytes();
TelephoneListMIDlet.pd.editRecord(Integer.parseInt(recordno), rec, rec.length);
}
else if (c == backCommand)
{
Display.getDisplay(TelephoneListMIDlet.instance).setCurrent(
TelephoneListMIDlet.instance.getForm());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -