5 Replies Latest reply: Mar 7, 2012 9:07 AM by 922378 RSS

    Calling different lists in command action in j2me

    843849
      I have created a midlet with multiple lists and after user select one list element he will be directed to another list.I want to call these lists in command actions using List.SELECT_COMMAND and list_one.getselectedIndex( ).It works for only first list and "done" is displayed on listScreen1 when the first index of listScreen1 is selected . As well as again "done " is displayed when the first index of ListScreen2 is selected.How Should i over come from here?I have used switch case also for this instead of If condition and same problem exists.Please help me.Thanx a lot.


      if (c==List.SELECT_COMMAND )
      {
      if(listScreen1.getSelectedIndex()==0)
      {
      Display.getDisplay(parent).setCurrent(ListScreen2);
      ListScreen2.addCommand(BACK);
      ListScreen2.addCommand(OK);
      ListScreen2.setCommandListener(this);
      }

      if(listScreen1.getSelectedIndex()==1)
      {
      Display.getDisplay(parent).setCurrent(ListScreen3);
      ListScreen3.addCommand(BACK);
      ListScreen3.addCommand(OK);
      ListScreen3.setCommandListener(this);
      }

      if(listScreen1.getSelectedIndex()==2)
      {
      Display.getDisplay(parent).setCurrent(ListScreen4);
      ListScreen4.addCommand(BACK);
      ListScreen4.addCommand(OK);
      ListScreen4.setCommandListener(this);
      }

      else
      {
      System.err.println("Unexpected choice...");
      }
      return;
      }

      if (c==List.SELECT_COMMAND )

      {

      if(ListScreen2.getSelectedIndex()==0)

      {

      ListScreen2.append("done", null);
                
                }
      }