LIST的简单问题,希望大家帮忙看看.
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Interface extends MIDlet
implements CommandListener {
Display display;
List menu;
List choose;
Form helpinfo;
List input;
Form me;
Ticker ticker = new Ticker(
"Welcome to Map System!");
DateField date = new DateField("Today's date: ", DateField.DATE);
Form form = new Form("Form for Stuff");
Form today = new Form("Today's date");
Gauge gauge = new Gauge("Progress Bar", false, 20, 9);
TextField textfield = new TextField(
"TextField Label", "abc", 50, 0);
static final Command backCommand =
new Command("Back", Command.BACK, 0);
static final Command mainMenuCommand =
new Command("Main", Command.SCREEN, 1);
static final Command exitCommand =
new Command("Exit", Command.STOP, 2);
String currentMenu;
public Interface() {}
public void startApp() throws
MIDletStateChangeException {
display = Display.getDisplay(this);
menu = new List(
"Function List", Choice.IMPLICIT);
menu.append("Building List", null);
menu.append("View Date", null);
menu.append("Help", null);
menu.append("About Software", null);
menu.append("View Map", null);
menu.addCommand(exitCommand);
menu.setCommandListener(this);
menu.setTicker(ticker);
mainMenu();
form.append(gauge);
form.append(textfield);
// today
today.append(date);
}
public void pauseApp() {
display = null;
choose = null;
menu = null;
ticker = null;
form = null;
today = null;
input = null;
gauge = null;
textfield = null;
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
void mainMenu() {
display.setCurrent(menu);
currentMenu = "Main";
}
public void commandAction(Command c,
Displayable d) {
String label = c.getLabel();
if (label.equals("Exit")) {
destroyApp(true);
} else if (label.equals("Back")) {
if(currentMenu.equals("input")
|| currentMenu.equals("date")
|| currentMenu.equals("helpinfo")
|| currentMenu.equals("me")){
mainMenu();
}
} else {
List down = (List)display.getCurrent();
switch(down.getSelectedIndex()) {
case 0: BuildingList();break;
case 1: ViewDate();break;
case 2: Help();break;
case 3: AboutMe();break;
}
}
}
public void ViewDate() {
java.util.Date now = new java.util.Date();
date.setDate(now);
today.addCommand(backCommand);
today.setCommandListener(this);
display.setCurrent(today);
currentMenu = "date";
}
public void AboutMe() {
me = new Form("Software Introdution");
StringItem Intro1 = new StringItem
("Developer:", "YiHua Bao");
StringItem Intro2 = new StringItem
("StudentID:", "04912357");
StringItem Intro3 = new StringItem
("Year:", "2004-2005");
me.append(Intro1);
me.append(Intro2);
me.append(Intro3);
me.setTicker(new Ticker("Final Year Project"));
me.addCommand(backCommand);
me.setCommandListener(this);
display.setCurrent(me);
currentMenu = "me";
}
public void Help() {
helpinfo = new Form("Help Information");
StringItem Help1 = new StringItem
("View Description:", "Select the Bilding List option in the main menu->Select the Building you want->Select View Description Option.");
StringItem Help2 = new StringItem
("Search Building:", "Select the Bilding List option in the main menu->Select the Building you want->Select Show Building Option.");
StringItem Help3 = new StringItem
("View Map:", "Select the Building List option in the main menu->Use the Hotkey(Left, Right, Up, Down) to move the map.");
StringItem Help4 = new StringItem
("ZoomIn & ZoomOut:","Use the HotKey for ZoomIn & ZoomOut when the map is displayed.");
helpinfo.append(Help1);
helpinfo.append(Help2);
helpinfo.append(Help3);
helpinfo.append(Help4);
helpinfo.setTicker(new Ticker("Welcome to use Help"));
helpinfo.addCommand(backCommand);
helpinfo.setCommandListener(this);
display.setCurrent(helpinfo);
currentMenu = "helpinfo";
}
public void BuildingList() {
input = new List(
"Bilding List", Choice.IMPLICIT);
input.append("1. Lipman Building", null);
input.append("2. Squires Building", null);
input.append("3. Squires Annexe", null);
input.append("4. Newcastle College", null);
input.append("5. Library", null);
input.append("6. Art Gallery", null);
input.append("7. Student Service", null);
input.append("8. Students' Union", null);
input.append("9. Northumberland Building", null);
input.append("10. Northumbrialand Annexe", null);
input.append("11. College House", null);
input.append("12. Sutherland Building", null);
input.append("13. Trinity Building", null);
input.append("14. Ellison Building", null);
input.append("15. rutherford Hall", null);
input.append("16. Ellison terrace", null);
input.append("17. Wynne-Jones Center", null);
input.append("18. Pardon Building", null);
input.append("19. 21 & 22 Ellison Terrace", null);
input.append("20. Claude Gibb Hall", null);
input.append("21. Lovaine Hall", null);
input.append("22. Sport Centre", null);
input.append("23. Newcastle Unitarian Church", null);
input.append("24. St James' Church", null);
input.append("25. Health Center", null);
input.append("26. Burt Hall", null);
input.append("27. Glenamara House", null);
input.append("28. North Terrace", null);
input.append("29. Drill Hall", null);
input.append("30. Legal Service Unit", null);
input.append("31. SSR Centre", null);
input.append("32. Technopole", null);
input.append("33. Nixon Hall", null);
input.setTicker(new Ticker("Select The Building Here"));
input.addCommand(backCommand);
input.setCommandListener(this);
display.setCurrent(input);
currentMenu = "input";
}
}
当我进到BUILDINGLIST里面又会回到,MAINMENU的几个选项,怎样可以把他们分开并当我选XXXX BUDILING的时候有关于这个BUILDING的选项呢?
谢谢大家帮忙.