/**
* @author You Li
*
* CopyRight (C) 2005 www.iguess.com.cn
*/
public class FormTest extends MIDlet implements CommandListener,ItemStateListener {
private Display display;
Command commit ;
public FormTest() {
display = Display.getDisplay(this);
// TODO 自动生成构造函数存根
}
protected void startApp() throws MIDletStateChangeException {
// TODO 自动生成方法存根
commit = new Command("Commit",Command.SCREEN,1) ;
Form f = new Form("FormTest") ;
f.append("String 1") ;//相当于new StringItem(null,"String 1")
f.append("String 2") ;
f.append(new StringItem("Label 1 ","Content 2")) ;
f.append(new StringItem("Label 2 ","Content 2")) ;
f.addCommand(commit) ;
f.setCommandListener(this) ;
f.setItemStateListener(this) ;
display.setCurrent(f) ;
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO 自动生成方法存根
}
public void commandAction(Command c, Displayable s) {
// TODO 自动生成方法存根
Form tmp = (Form) s ;
for(int i = 0;i
StringItem si = (StringItem) tmp.get(i);
//get()方法取回值是Item类,所以需要强制转化味StringItem类。
System.out.println(si.getText());
}
}
public void itemStateChanged(Item arg0) {
// TODO 自动生成方法存根