phoneList.java
上传用户:anders
上传日期:2022-07-15
资源大小:376k
文件大小:2k
- package phoneLeter;
- import java.util.Vector;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.List;
- import javax.microedition.lcdui.Command;
- public class phoneList extends List implements CommandListener{
- private Command cmdBack=new Command("返回",Command.BACK,1);
- private Command cmdAdd=new Command("添加电话",Command.SCREEN,1);
- private Command cmdDel=new Command("删除电话",Command.SCREEN,1);
- private phoneMIDlet pm;
-
- public phoneList(phoneMIDlet pm) {
- super("通讯录",List.IMPLICIT);
- this.pm=pm;
- this.addCommand(cmdBack);
- this.addCommand(cmdAdd);
- this.addCommand(cmdDel);
- this.setCommandListener(this);
- }
- public void commandAction(Command arg0, Displayable arg1) {
- if(arg0==cmdBack)
- {
- //返回欢迎界面
- pm.changeInterface("WelcomeCanvas");
- }
- else if(arg0==cmdAdd)
- {
- //添加电话界面
- pm.changeInterface("addPhone");
- }
- else if(arg0==cmdDel)
- {
- //删除电话
- this.delete();
- //更新
- pm.changeInterface("phoneList");
- }
-
- }
- //载入所有电话
- public void loadPhones()
- {
- RMSope rmsope=new RMSope("PhoneStore");
- rmsope.openRecordStore();
- Vector v=rmsope.getAllPhone();
- for(int i=0;i<v.size();i++)
- {
- this.append((String)v.elementAt(i), null);
- }
- rmsope.closeRecordStore();
- }
-
- //删除电话
- public void delete()
- {
- RMSope rmsope=new RMSope("PhoneStore");
- rmsope.openRecordStore();
- rmsope.deletePhone(this.getString(this.getSelectedIndex()));
- }
- }