📄 editmenuscreen.java
字号:
package junwei;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import rms.*;
/**
* 设置点菜项目的数量、口味要求、状态
* @author hong
*
*/
public class EditMenuScreen extends InputScreen implements CommandListener{
private static EditMenuScreen instance;
private static TextField textAmount;
private static ChoiceGroup choiceRemark;
private static TextField textOther;
private static ChoiceGroup choiceStatus;
synchronized public static EditMenuScreen getInstance() {
if (instance == null)
instance = new EditMenuScreen();
BillDetail aBillDetail=AddMenuScreen.getInstance().getSelectDetail();
textAmount.setString(String.valueOf(aBillDetail.getAmount()));
for (int j=0;j<choiceRemark.size();j++)
choiceRemark.setSelectedIndex(j,false);
textOther.setString("");
if (!aBillDetail.getRemark().equals(""))
{
String remarks[] = MainMidlet.splitString(aBillDetail.getRemark(),
',');
boolean hasSelect;
for (int i = 0; i < remarks.length; i++) {
hasSelect = false;
for (int j = 0; j < choiceRemark.size(); j++) {
if (choiceRemark.getString(j).equals(remarks[i])) {
choiceRemark.setSelectedIndex(j, true);
hasSelect = true;
break;
}
}
if (!hasSelect) {
if (!textOther.getString().equals(""))
textOther.setString(textOther.getString() + ",");
textOther.setString(textOther.getString() + remarks[i]);
}
}
}
choiceStatus.setSelectedIndex(aBillDetail.getStatusID(),true);
return instance;
}
private EditMenuScreen() {
super("菜品设置");
textAmount=new TextField("数量:","",6,Item.PLAIN|TextField.DECIMAL);
append(textAmount);
choiceRemark=new ChoiceGroup("客人要求:",Choice.MULTIPLE);
RecordStore rs = RMSUtil.openRSAnymay(MainMidlet.RMS_TASTE);
if (rs != null) {
try {
RecordEnumeration re = rs.enumerateRecords(null, null, false);
Syscode aTaste;
while (re.hasNextElement()) {
byte[] data = re.nextRecord();
aTaste=Syscode.decode(data);
choiceRemark.append(aTaste.getName(),null);
}
rs.closeRecordStore();
} catch (Exception e) {
System.out.println(e.toString());
}
}
append(choiceRemark);
textOther=new TextField("其他要求:","",30,Item.PLAIN);
append(textOther);
choiceStatus=new ChoiceGroup("菜品状态:",Choice.EXCLUSIVE);
choiceStatus.append("正常",null);
choiceStatus.append("等叫",null);
choiceStatus.append("已上",null);
append(choiceStatus);
addCommand(new Command("确定", Command.OK, 1));
addCommand(new Command("取消", Command.CANCEL, 1));
setCommandListener(this);
}
public void commandAction(Command c, Displayable s) {
String cmd = c.getLabel();
if (cmd.equals("确定")) {
String remark = "";
boolean[] seleted=new boolean[choiceRemark.size()];
if (choiceRemark.getSelectedFlags(seleted) > 0) {
for (int i = 0; i < seleted.length; i++) {
if (seleted[i]) {
if (!remark.equals(""))
remark += ",";
remark += choiceRemark.getString(i);
}
}
}
if (!textOther.getString().equals("")) {
if (!remark.equals(""))
remark += ",";
remark += textOther.getString();
}
AddMenuScreen.getInstance().editMenu(
Float.valueOf(textAmount.getString()).floatValue(), remark,
choiceStatus.getSelectedIndex());
}
Navigator.display.setCurrent(AddMenuScreen.getInstance());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -