?? list1.java
字號:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class List1 extends MIDlet implements CommandListener,ItemStateListener {
private final static Command exitCommand = new Command("Exit", Command.EXIT, 1);
private Display display;
private Form mainForm;
private TextField textfield;
private ChoiceGroup group ;
public List1() {
}
protected void startApp() {
display = Display.getDisplay(this);
mainForm = new Form("Choice Group");
mainForm.append("These are the available choice group");
Image[] imageArray = null;
try {
// load the duke image to place in the image array
Image duke = Image.createImage("/Icon.png");
// these are the images and strings for the choices.
imageArray = new Image[] { duke, duke, duke, duke };
} catch (java.io.IOException err) {
// ignore the image loading failure the application can recover.
}
String[] stringArray = { "選項 A", "選項 B", "選項 C", "選項 D" };
//group = new ChoiceGroup("Exclusive", ChoiceGroup.EXCLUSIVE,
// stringArray, imageArray);
//group = new ChoiceGroup("Multiple", ChoiceGroup.MULTIPLE, stringArray,
// imageArray);
//創建 Pop-Up類型的ChoiceGroup,只能在MIDP2.0平臺才有
group = new ChoiceGroup("Pop-Up", ChoiceGroup.POPUP, stringArray,
imageArray);
textfield = new TextField("當前選項為:","選項 A",20,TextField.ANY);
mainForm.append(group);
mainForm.append(textfield);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
mainForm.setItemStateListener(this);
display.setCurrent(mainForm);
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
}
public void itemStateChanged(Item item) {
if( item instanceof ChoiceGroup)
{
textfield.setString(group.getString(group.getSelectedIndex()));
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -