Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

J2ME : How to get data from listing menu

Posted on 2006-04-06
5
Medium Priority
?
465 Views
Last Modified: 2008-03-03
Hello,
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
0
Comment
Question by:eddysusanto
  • 3
  • 2
5 Comments
 

Author Comment

by:eddysusanto
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";
            inkarta.koneksi(url);
            km=inkarta.hasilStatus;
            if (km.equals("NO"))
            {
                  infoForm = new Form("Info");
                  infoForm.append("Tidak ada Info");
                  kembaliCommand = new Command("Back", Command.CANCEL, 1);
                  infoForm.addCommand(kembaliCommand);
                  infoForm.setCommandListener(this);
                  display.setCurrent(infoForm);
         }
         else
         {
            jumlah=km.length();
            awal=0;
            listInfo = new List("Pilih",List.IMPLICIT);

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

                        hsl=km.substring(ulang,ulang+1);
                        if (hsl.equals(","))
                        {
                              subyek=km.substring(awal,ulang);
                              awal=ulang+1;
                                listInfo.append (subyek, null);
                        }

                  }

            kembaliCommand = new Command("Back", Command.CANCEL, 1);
            listInfo.addCommand(kembaliCommand);
            detailCommand = new Command("Detail", Command.OK, 2);
            listInfo.addCommand(detailCommand);
            listInfo.setCommandListener(this);
            display.setCurrent(listInfo);
            }
      }

    public void infoDetail()
      {
            url = "http://localhost/inkarta/j2me/dtljadwaljktyog.php?kode="+kodea;  << I need string for variabel kodea
            inkarta.koneksi(url);
            formDetail =new Form("Detail Info");
            formDetail.append(inkarta.hasilStatus);
            keluarDetailCommand = new Command("Back", Command.CANCEL, 3);
            formDetail.addCommand(keluarDetailCommand);
            formDetail.setCommandListener(this);
            display.setCurrent(formDetail);
      }

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

Expert Comment

by:bglodde
ID: 16401375
Try this:

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

Author Comment

by:eddysusanto
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);
                                            ^


0
 
LVL 13

Accepted Solution

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

Author Comment

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

Best regards
0

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