J2ME : How to get data from listing menu

Posted on 2006-04-06
Last Modified: 2008-03-03
I'm new in J2ME. I need your help to solve my problem.

I use php to retrieve data from mysql to my j2me application the outcome is in lists of data.
After I get a list of data, the list can be selected for data details.

String A
String B
String C

if using this command, index = listInfo.getSelectedIndex();  
the result is only index data in interger

After selected String A, what command should i use in order that i can get "String A" data in text not just the index.

Thank you
Best regards
Question by:eddysusanto

    Author Comment

    import javax.microedition.lcdui.*;

    class jadwaljktyog extends Form implements CommandListener  {
          private Inkarta inkarta;
          private Display display;
          private TextField kodeField;
          private Command detailCommand;
          private Command kembaliCommand;
          private Command keluarDetailCommand;
          private List listInfo;
          private Form formDetail;
          private Form infoForm;

          String kodea, coba, dapatStatus, olehStatus, ada, km, hsl, subyek;

          int index, jumlah, awal;
          Image infoImage;

          String url = null;

          jadwaljktyog (Inkarta inkarta) {
                super ("Info Jadwal JKT-YOG Yg Ada");
                this.inkarta = inkarta;
                ada = null;
                dapatStatus = null;
                olehStatus = null;
                display = Display.getDisplay (inkarta);


    public void awal()
                url = "http://localhost/inkarta/j2me/jadwaljktyog.php";
                if (km.equals("NO"))
                      infoForm = new Form("Info");
                      infoForm.append("Tidak ada Info");
                      kembaliCommand = new Command("Back", Command.CANCEL, 1);
                listInfo = new List("Pilih",List.IMPLICIT);

                      int ulang;
                      for (ulang = 0 ; ulang < jumlah; ulang++)

                            if (hsl.equals(","))
                                    listInfo.append (subyek, null);


                kembaliCommand = new Command("Back", Command.CANCEL, 1);
                detailCommand = new Command("Detail", Command.OK, 2);

        public void infoDetail()
                url = "http://localhost/inkarta/j2me/dtljadwaljktyog.php?kode="+kodea;  << I need string for variabel kodea
                formDetail =new Form("Detail Info");
                keluarDetailCommand = new Command("Back", Command.CANCEL, 3);

          public void commandAction(Command c, Displayable d)
                if (c == kembaliCommand )
            else if (c == detailCommand )
                      index = listInfo.getSelectedIndex();
                      kodea= ??? <<<<<<< THIS line .. I don't know what syntax I should use
    LVL 13

    Expert Comment

    Try this:

    index = listInfo.getSelectedIndex();
    kodea = listInfo.getText(index);

    Author Comment

    I got error msg with that line

    Building "Inkarta"
    c:\WTK104\apps\Inkarta\src\ cannot resolve symbol
    symbol  : method getText  (int)
    location: class javax.microedition.lcdui.List
                      kode = listInfo.getText(index);

    LVL 13

    Accepted Solution

    I'm sorry, that should be getString(index);

    Author Comment

    wow ... that's the answer
    Thank you very much

    Best regards

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
    DECT technology has become a popular standard for wireless voice communication. DECT devices are not likely to be affected by other electronic devices and signals because they operate in a separate frequency-band.
    This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now