Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7875907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:04:42+00:00 2026-06-03T03:04:42+00:00

EDIT: I believe I need help getting the selected element in the list I

  • 0

EDIT: I believe I need help getting the selected element in the list I just managed
for it to display a new form but I’m having a lot of trouble finding code that works
with source 3.0.

I’ve been trying to make a application that allows a user to select a date then add
and remove events based on the selected date. So far I have created the first screen
which is a list of option for the user to choose from.
These options are:

  • Select Date
  • Add Events
  • Remove Events
  • Browse Events

The issues I’m having is I can’t get my head around how to display new forms based on
the selected Item in the list. I found a small tutorial that allowed me to add a command
listener which shows the selected item but I’m having trouble figuring out how it gets the
item selected in the list and how I could create a new form based on the item selected?

Here’s my code so far.

    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.List;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;

    public class mainMidlet extends MIDlet implements CommandListener {

      private Display display;
      private List list = new List("Please Select a Option", List.IMPLICIT);
      private Command select = new Command("Select", Command.SCREEN, 1);
      private Form form;
      Alert alert;

      public mainMidlet() {
        display = Display.getDisplay(this);   

        list.append("Select Date", null);
        list.append("Add Events", null);
        list.append("Remove Events", null);
        list.append("Browse Events", null);
        list.addCommand(select);
        list.setCommandListener(this);

      }

      public void startApp() {
        display.setCurrent(list);
      }

      public void pauseApp() {
      }

      public void destroyApp(boolean unconditional) {
      }

      public void commandAction(Command command, Displayable displayable) {
        if (command == List.SELECT_COMMAND) {
          String selection = list.getString(list.getSelectedIndex());
          alert = new Alert("Option Selected", selection, null, null);
          alert.setTimeout(Alert.FOREVER);
          alert.setType(AlertType.INFO);
          display.setCurrent(alert);
        } else if (command == select) {
          destroyApp(false);
          notifyDestroyed();
        }
      }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:04:43+00:00Added an answer on June 3, 2026 at 3:04 am

    You can add several forms and switch between them

      public void commandAction(Command command, Displayable displayable) {
          if (displayable == list) {
              if (command == List.SELECT_COMMAND) {
                  switch (list.getSelectedIndex()) {
                      case 0: // select date
                          display.setCurrent(someForm);
                          break;
                      case 1: //add events
                          display.setCurrent(someOtherForm);
                          break;
                  }
              } else if (command == select) {
                 destroyApp(false);
                 notifyDestroyed();
              }
          }
          if (displayable == someForm) {
              //but it's better practice to make each form a different class implementing CommandListener and it's own commandAction. And leave the display public static in MIDlet class
              //...
          }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you enter edit mode for a UITableView (grouped but I believe this applies
EDIT: I believe i may have found the problem. I need to work on
Not having much luck getting help from any of you Spring gurus on here.
THIRD EDIT: I now believe that this problem is due to a SOAP version
EDIT: OK, I believe the following solutions are valid: Use the jQuery AOP plugin.
EDIT: Modified title and added update. UPDATE : We no longer believe this is
Firstly, thanks for your help. Here's my situation: I'm trying to edit the code
I'm hoping non-IIS people can help me on this though the issue I'm having
I need simple way to persist and edit a set of string pairs in
In my application (Delphi), I need to list all the USB storage devices. These

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.