⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exlistmidlet.java

📁 j2me接口的例子,很不错的东东 可以做教程
💻 JAVA
字号:
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ExListMIDlet extends MIDlet implements CommandListener {

    private Command exitComm;
    private Command confirmComm;

    private List list;
    private Display display;

    String[] job = {
        "程序员", "系统架构师", "开发员"};
    
    Image[] jobImage = { createImage("/App.png"), createImage("/PushPuzzle.png"),
        createImage("/Stock.png")};

    
    //The display for this MIDlet
    public ExListMIDlet() {

        display = Display.getDisplay(this);

        exitComm = new Command("离开", Command.EXIT, 1);
        confirmComm = new Command("确认", Command.SCREEN, 1);

    }

    public void startApp() {
    	
    	list = new List("职业", List.EXCLUSIVE, job, jobImage);
        list.addCommand(exitComm);
        list.addCommand(confirmComm);
      
        list.setCommandListener(this);
        display.setCurrent(list);

      
    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) {}

    private Image createImage(String name) {
        Image aImage = null;
        try {
            aImage = Image.createImage(name);
        } catch (IOException e) {
        }
        return aImage;
    }

    public void commandAction(Command c, Displayable s) {
    	
    	String comm = c.getLabel();
        if (comm.equals("离开")) {
                destroyApp(false);
                notifyDestroyed();
        }
        if (comm.equals("确认")) {
            Alert alert;   
            int index = list.getSelectedIndex();
            alert = new Alert("结果", job[index], null, AlertType.INFO);
            display.setCurrent(alert);
            }         
    
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -