PhoneView.java
上传用户:heyongping
上传日期:2022-07-01
资源大小:95k
文件大小:2k
- /*
- * 创建于 2009-12-04
- * 实现控制屏幕及相关事件监听
- *
- * 更改注释格式可以:Window - Preferences - Java - Code Style - Code Templates
- */
- package net.garrey.view;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.StringItem;
- import net.garrey.model.PhoneItem;
- 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 PhoneView extends Form{
- private UIController controller;
- private Command BACK_COMMAND;
- private StringItem nameField;
- private StringItem phoneField;
-
- public PhoneView(String title,UIController control){
- super(title);
- controller=control;
- this.setCommandListener(new PhoneViewListener());
-
- BACK_COMMAND=new Command("返回",Command.BACK,1);
- this.addCommand(BACK_COMMAND);
-
- nameField=new StringItem("名字 : ","");
- phoneField=new StringItem("电话 : ","");
- this.append(nameField);
- this.append(phoneField);
- }
-
- public void setPhone(PhoneItem item){
- nameField.setText(item.getName());
- phoneField.setText(item.getPhonenum());
- }
- //监听器
- private class PhoneViewListener implements CommandListener{
- public void commandAction(Command command, Displayable disp){
- if(command==BACK_COMMAND){
- controller.handleEvent(UIController.EventID.EVENT_VIEW_BACK,null);
- }
- }
- }//end inner class
- }