📄 deletefriendscreen.java
字号:
package telphonebook;
import java.util.Vector;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;
public class DeleteFriendScreen extends List implements CommandListener {
private static final String DELETE = "鍒犻櫎";
private Vector friendID;
public DeleteFriendScreen() {
super(Constant.TITLE_DELETE_FRIEND_SCREEN, Choice.MULTIPLE);
initCommand();
initFriendInfo();
}
private void initFriendInfo() {
try {
RecordEnumeration re = Constant.telphoneStore.enumerateRecords(
null, new NameComparator(), true);
friendID = new Vector();
while (re.hasNextElement()) {
int id = re.nextRecordId();
friendID.addElement(new Integer(id));
Account friend = Account.decode(Constant.telphoneStore
.getRecord(id));
append(friend.getName(), null);
}
re.destroy();
} catch (RecordStoreNotOpenException e) {
e.printStackTrace();
} catch (InvalidRecordIDException e) {
e.printStackTrace();
} catch (RecordStoreException e) {
e.printStackTrace();
}
}
private void initCommand() {
addCommand(new Command(DELETE, Command.OK, 0));
addCommand(Constant.BACK_COMMAND);
setCommandListener(this);
}
public void commandAction(Command cmd, Displayable arg1) {
String label = cmd.getLabel();
if (label.equals(DELETE)) {
delete();
} else if (label.equals(Constant.BACK)) {
Constant.toMainScreen();
}
}
private void delete() {
int count = friendID.size();
if (count == 0)
return;
deleteFriend(count);
updateScreen();
}
private void updateScreen() {
deleteAll();
initFriendInfo();
}
private void deleteFriend(int count) {
boolean[] selects = new boolean[count];
getSelectedFlags(selects);
for (int i = 0; i < count; i++) {
if (selects[i]) {
try {
Constant.telphoneStore.deleteRecord(((Integer) friendID
.elementAt(i)).intValue());
} catch (RecordStoreNotOpenException e) {
e.printStackTrace();
} catch (InvalidRecordIDException e) {
e.printStackTrace();
} catch (RecordStoreException e) {
e.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -