×

Discussion Board

Results 1 to 8 of 8

Thread: List menu items

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    List menu items

    in my app i have list items but when i select any of them i get application error in the real device.
    i want when i select like any of them to be taken to things like exit, help.am using lcdui
    thanks.

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: List menu items

    Hi

    Does the error occur in emulator as well ?
    Kindly share the code snippet on what executes when u click on the list.

    Regards,
    Arun.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,698

    Re: List menu items

    You may also consider checking what that error (exception?) actually is.
    It may also matter what devices you are using. On Asha platform, there are things what you can not do in the UI thread. See http://developer.nokia.com/Resources...tive-apis.html.

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    list menu items

    in the emulator screen, it brings a message saying something went wrong running this app;
    here is the code snippet

    / command
    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 = null;

    // constructor.
    public EventEx1() {
    }

    /**
    * Start the MIDlet by creating a list of items and associating the
    * exit command with it.
    */
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);

    menu = new List("Menu Items", Choice.IMPLICIT);
    menu.append("exit", null);
    menu.append("help", null);
    menu.append("Item3", null);
    menu.append("Item4", null);
    menu.addCommand(exitCommand);
    menu.setCommandListener(this);

    mainMenu();
    }

    public void pauseApp() {
    display = null;
    menu = null;
    input = null;
    }

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

    // main menu
    void mainMenu() {
    display.setCurrent(menu);
    currentMenu = "Main";
    }

    /**
    * a generic method that will be called when selected any of
    * the items on the list.
    */
    public void prepare() {
    input = new TextBox("Enter some text: ", "", 5, TextField.ANY);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    }

    /**
    * exit
    */
    public void exit() {
    prepare();
    currentMenu = "exit";
    }

    /**
    * help
    */
    public void help() {
    prepare();
    currentMenu = "help";
    }

    /**
    * Test item3.
    */
    public void testItem3() {
    prepare();
    currentMenu = "item3";
    }

    /**
    * Test item4.
    */
    public void testItem4() {
    prepare();
    currentMenu = "item4";
    }


    /**
    * Handle events.
    */
    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("item1") || currentMenu.equals("item2") ||
    currentMenu.equals("item3") || currentMenu.equals("item4")) {
    // go back to menu
    mainMenu();
    }

    } else {
    List down = (List)display.getCurrent();
    switch(down.getSelectedIndex()) {
    case 0: exit();break;
    case 1: help();break;
    case 2: testItem3();break;
    case 3: testItem4();break;
    }

    }
    }
    }

    i want when like i select exit on the list, should exit the app and when i select help, it should take me to the textbox containing help information but with also a back command to take me back to the list menu.
    thanks
    Last edited by juliusa; 2014-01-10 at 09:01.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,698

    Re: list menu items

    Your threads are merged now. Creating a new thread "list menu items", immediately next to the old one "List menu items" is not necessarily a good practice.

  6. #6
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    Re: List menu items

    in the emulator it says something went wrong running this app.
    here is the code snippet;

    / command
    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 = null;

    // constructor.
    public EventEx1() {
    }

    /**
    * Start the MIDlet by creating a list of items and associating the
    * exit command with it.
    */
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);

    menu = new List("Menu Items", Choice.IMPLICIT);
    menu.append("exit", null);
    menu.append("help", null);
    menu.append("Item3", null);
    menu.append("Item4", null);
    //menu.addCommand(exitCommand);
    //menu.setCommandListener(this);

    mainMenu();
    }

    public void pauseApp() {
    display = null;
    menu = null;
    input = null;
    }

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

    // main menu
    void mainMenu() {
    display.setCurrent(menu);
    currentMenu = "Main";
    }

    /**
    * a generic method that will be called when selected any of
    * the items on the list.
    */
    public void prepare() {
    input = new TextBox("Enter some text: ", "", 5, TextField.ANY);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    }

    /**
    * exit
    */
    public void exit() {
    prepare();
    currentMenu = "exit";
    }

    /**
    * help
    */
    public void help() {
    prepare();
    currentMenu = "help";
    }

    /**
    * Test item3.
    */
    public void testItem3() {
    prepare();
    currentMenu = "item3";
    }

    /**
    * Test item4.
    */
    public void testItem4() {
    prepare();
    currentMenu = "item4";
    }


    /**
    * Handle events.
    */
    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("item1") || currentMenu.equals("item2") ||
    currentMenu.equals("item3") || currentMenu.equals("item4")) {
    // go back to menu
    mainMenu();
    }

    } else {
    List down = (List)display.getCurrent();
    switch(down.getSelectedIndex()) {
    case 0: exit();break;
    case 1: help();break;
    case 2: testItem3();break;
    case 3: testItem4();break;
    }

    }
    }
    }

    i want when like i select exit on the list, should exit the app and when i select help, it should take me to the textbox containing help information but with also a back command to take me back to the list menu.
    thanks

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: List menu items

    Is that the new Asha Software Platform (Nokia Asha 501, Nokia Asha 502)?
    Does the whole emulator crash or is nothing on the console window?

  8. #8
    Regular Contributor
    Join Date
    Mar 2005
    Location
    Hamburg, Germany
    Posts
    284

    Re: List menu items

    First try to get information what has exaclty happen and where it exactly happen.

    Build your app with debug information and without obfuscation.
    Than when you run the app in the emulator,
    look at your IDE. Somewhere there is an output window, and it will display an exception.
    This exception has a type and a filename/linenumber.

    With this information you find the bug much quicker.


    Regards

    Karsten Meier

Similar Threads

  1. Replies: 11
    Last Post: 2010-06-28, 23:22
  2. List application icon on phone menu list(menu page)
    By sreehari434 in forum Mobile Java General
    Replies: 9
    Last Post: 2009-07-13, 10:54
  3. MTM: custom menu items in Message list view
    By alphaMail in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2008-08-14, 13:37
  4. Replies: 0
    Last Post: 2008-07-11, 16:24
  5. How to add items dynamically to the double pop menu style list box
    By vinayakak in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-12-07, 08:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×