Learn how to a build a cloud-first strategyRegister Now


J2ME : How to get data from listing menu

Posted on 2006-04-06
Medium Priority
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
  • 3
  • 2

Author Comment

ID: 16397267
import javax.microedition.lcdui.*;
import java.io.IOException;

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

ID: 16401375
Try this:

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

Author Comment

ID: 16401631
I got error msg with that line

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

LVL 13

Accepted Solution

bglodde earned 1000 total points
ID: 16401845
I'm sorry, that should be getString(index);

Author Comment

ID: 16401929
wow ... that's the answer
Thank you very much

Best regards

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hopefully this article will help someone who's had the same issues I had. I have a Dell Wireless 1390 WLAN Mini-Card and Windows 7, and for the past couple of days I was beyond frustrated because my wireless laptop was not able to access the Inte…
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
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…
Suggested Courses

810 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