PhoneFind.java
上传用户:heyongping
上传日期:2022-07-01
资源大小:95k
文件大小:3k
- /*
- * 创建于 2009-12-04
- * 实现控制屏幕及相关事件监听
- *
- * 更改注释格式可以:Window - Preferences - Java - Code Style - Code Templates
- */
- package net.garrey.view;
- import java.util.Vector;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.Image;
- import javax.microedition.lcdui.StringItem;
- import javax.microedition.lcdui.TextField;
- import net.garrey.model.PhoneItem;
- import net.garrey.util.PhoneRecordStore;
- import net.garrey.util.UIController;
- /**
- * @author Administrator
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
- public class PhoneFind extends Form{
- private UIController controller;
- private Command BACK_COMMAND;
- private Command FINDOK_COMMAND;
- private StringItem nameField;
- private StringItem phoneField;
- private Vector items;
- private Image icon;
- private static String keyValue;
-
- private TextField phoneFindText;
-
-
-
- public PhoneFind(String title,UIController control){
- super(title);
- controller=control;
- this.setCommandListener(new PhoneViewListener());
-
- BACK_COMMAND=new Command("返回",Command.BACK,1);
- FINDOK_COMMAND=new Command("开始查询",Command.SCREEN,1);
- this.addCommand(BACK_COMMAND);
- this.addCommand(FINDOK_COMMAND);
-
-
- phoneFindText=new TextField("输入查询条件:","",30,TextField.ANY);
-
-
- // nameField=new StringItem("名字 : ","");
- // phoneField=new StringItem("电话 : ","");
- // this.append(nameField);
- // this.append(phoneField);
-
- this.append(phoneFindText);
- }
- public static String getKeyValue(){
- return keyValue;
- }
- public void setPhone(PhoneItem item){
- nameField.setText(item.getName());
- phoneField.setText(item.getPhonenum());
- }
- /*
- * 实现信息的刷新
- */
- public void refresh(Vector vec){
- this.deleteAll();
- this.items=vec;
- if(vec!=null&&vec.size()>0){
- PhoneItem phone=null;
- for(int i=0;i<vec.size();i++){
- phone=(PhoneItem)vec.elementAt(i);
- this.append(phone.getName()+","+phone.getPhonenum());
-
- }
- }
- }
- //监听器
- private class PhoneViewListener implements CommandListener{
- public void commandAction(Command command, Displayable disp){
- if(command==BACK_COMMAND){
- controller.handleEvent(UIController.EventID.EVENT_FIND,null);
- }else if(command==FINDOK_COMMAND){
- keyValue=phoneFindText.getString();
- controller.handleEvent(UIController.EventID.EVENT_VIEW_FINDOK,null);
- }
- }
- }//end inner class
- }