Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i wrote this code and created a list and i want to close app when
user choose Exit Game but it doesn't work!
what is wrong with this code?

package hello;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;

public class Midlet extends MIDlet implements CommandListener {

    private Display display;
    
    List Menu = new List("Choose One:", List.IMPLICIT);
    List Level_choose = new List("Choose One:", List.IMPLICIT);
    
    
    
  

    public void startApp() {
        display = Display.getDisplay(this);
        try {
            
            this.Menu.append("Start Game",null);
            
            this.Menu.append("Top Scores",null);
           
            this.Menu.append("About us",null);
            
            this.Menu.append("Exit Game",null);
            Menu.setCommandListener(this);
            display.setCurrent(Menu);
            Level_choose.setCommandListener(this);

        } catch (Exception e) {
            e.printStackTrace();
        }





    }

    public Display getDisplay() {
        return display;
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        notifyDestroyed();
    }

    public void exit() {
        System.gc();
        destroyApp(false);
        notifyDestroyed();
    }

    public void commandAction(Command c, Displayable d) {
        List li = (List) display.getCurrent();

        switch (li.getSelectedIndex()) {
            case 0:
                display.setCurrent(this.Level_choose);
                this.choosed = true;
                break;
            case 1:

            case 2:
                break;
            case 3:
                exit();
                

        }
       

        
    }
}
Posted
Updated 4-Jul-11 22:00pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900