📄 categoryslist.java
字号:
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.pim.PIMException;
import javax.microedition.pim.PIMList;
public class categorysList extends List implements CommandListener {
private final Command removeCommand=new Command("删除",Command.SCREEN,3);
private final Command newCommand=new Command("新建",Command.SCREEN,2);
private final Command selectCommand=new Command("查看",Command.OK,1);
private final Command backCommand=new Command("后退",Command.EXIT,1);
private final ContactListDemo midlet;
private final Displayable caller;
private final PIMList pList;
public categorysList(ContactListDemo _midlet,Displayable _displayable,PIMList _list) {
super("选择一个分组", List.IMPLICIT);
midlet=_midlet;
caller=_displayable;
pList=_list;
addCommand(removeCommand);
addCommand(newCommand);
addCommand(selectCommand);
addCommand(backCommand);
setCommandListener(this);
populateList();
}
public void commandAction(Command c, Displayable d) {
if(c==selectCommand){///显示电话本内联系人列表
Form form=new Form("载入电话本列表");
form.append("请等候...");
Display.getDisplay(midlet).setCurrent(form);
String catagoryName=getString(getSelectedIndex());
if(catagoryName.equals("未分组"))
catagoryName=PIMList.UNCATEGORIZED;
try {
((showPersonList)caller).setCurrentCategory(catagoryName);
((showPersonList)caller).populateList();
} catch (Exception e) {
e.printStackTrace();
}
Display.getDisplay(midlet).setCurrent(caller);
}
else if(c==backCommand){
Display.getDisplay(midlet).setCurrent(caller);
}
else if(c==newCommand){
Display.getDisplay(midlet).setCurrent(new catagoryForm(midlet,this,pList));
}
else if(c==removeCommand){
String catagoryName=getString(getSelectedIndex());
try {
pList.deleteCategory(catagoryName, true);
} catch (Exception e) {
e.printStackTrace();
}
populateList();
}
}
public void populateList()
{
deleteAll();
try {
String []cats=pList.getCategories();
for(int i=0;i<cats.length;i++){
append(cats[i], null);
}
append("未分组", null);
} catch (PIMException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -