c0e1503d0152001f185d87389a1c119f
上传用户:anders
上传日期:2022-07-15
资源大小:376k
文件大小:2k
源码类别:

J2ME

开发平台:

Java

  1. package phoneLeter;
  2. import java.util.Vector;
  3. import javax.microedition.lcdui.CommandListener;
  4. import javax.microedition.lcdui.Displayable;
  5. import javax.microedition.lcdui.List;
  6. import javax.microedition.lcdui.Command;
  7. public class phoneList extends List implements CommandListener{
  8. private Command cmdBack=new Command("返回",Command.BACK,1);
  9. private Command cmdAdd=new Command("添加电话",Command.SCREEN,1);
  10. private Command cmdDel=new Command("删除电话",Command.SCREEN,1);
  11. private phoneMIDlet pm;
  12. public phoneList(phoneMIDlet pm) {
  13. super("通讯录",List.IMPLICIT);
  14. this.pm=pm;
  15. this.addCommand(cmdBack);
  16. this.addCommand(cmdAdd);
  17. this.addCommand(cmdDel);
  18. this.setCommandListener(this);
  19. }
  20. public void commandAction(Command arg0, Displayable arg1) {
  21. if(arg0==cmdBack)
  22. {
  23. //返回欢迎界面
  24. pm.changeInterface("WelcomeCanvas");
  25. }
  26. else if(arg0==cmdAdd)
  27. {
  28. //添加电话界面
  29. pm.changeInterface("addPhone");
  30. }
  31. else if(arg0==cmdDel)
  32. {
  33. //删除电话
  34. this.delete();
  35. //更新
  36. pm.changeInterface("phoneList");
  37. }
  38. }
  39. //载入所有电话
  40. public void loadPhones()
  41. {
  42. RMSope rmsope=new RMSope("PhoneStore");
  43. rmsope.openRecordStore();
  44. Vector v=rmsope.getAllPhone();
  45. for(int i=0;i<v.size();i++)
  46. {
  47. this.append((String)v.elementAt(i), null)
  48. }
  49. rmsope.closeRecordStore();
  50. }
  51. //删除电话
  52. public void delete()
  53. {
  54. RMSope rmsope=new RMSope("PhoneStore");
  55. rmsope.openRecordStore();
  56. rmsope.deletePhone(this.getString(this.getSelectedIndex()));
  57. }
  58. }