Solved

J2ME lcdui.List problem

Posted on 2003-12-01
6
397 Views
Last Modified: 2013-11-23
I'm trying to build my application with the WTK2, but I'm always getting the following error message:

C:\WTK20\apps\Client\src\WVClient.java:413: cannot resolve symbol
symbol  : constructor List (java.lang.String,int,java.lang.String,<nulltype>)
location: class javax.microedition.lcdui.List
      NameSearchList = new List ("Name Search", List.IMPLICIT, resultSearch[0], null);

I can't find what's wrong with the List. I'm pasting below all the parts of this class that seem relevant for me.

import javax.microedition.lcdui.*;      // Command, Textfield, Form
import javax.microedition.midlet.*;      // MIDlet
import java.util.*;

...

private List NameSearchList;

...

private String phoneBookSearch;
private String[] resultSearch;
int busca;      // Usada para guardar o valor para uma nova busca de nome ou telefone

...

/**
 * Responsible for starting the name search
 */
public void setGetNameSearchList() {

      inputForm = new Form(null);
      TFitem1 = new TextField("Name", phoneBookSearch, 40, TextField.ANY);
      Ticker titulo = new Ticker ("NameSearch");
      inputForm.setTicker(titulo);
      inputForm.append(TFitem1);
      inputForm.addCommand(cancel);
      inputForm.addCommand(submit);
      inputForm.setCommandListener(this);
}

...

// "SetGetNameSearchList"
      case 5:
            NameSearch nameSearch = new NameSearch(con);
            busca = 1;
            resultSearch = nameSearch.getNameRequest(phoneBookSearch);
            NameSearchList = new List ("Name Search", List.IMPLICIT, resultSearch[0], null);
            NameSearchList.addCommand(cancel);
            NameSearchList.addCommand(newSearch);
            NameSearchList.setCommandListener(WVClient.this);
            display.setCurrent(NameSearchList);
            break;
...

Where NameSearch is another class I'm developing and the name of the current class is WVClient. If any other information is needed, please contact me.

0
Comment
Question by:mdytz
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 9850077
> symbol  : constructor List (java.lang.String,int,java.lang.String,<nulltype>)

  You are trying to create a List object by passing different number or types of arguments in the constructor... Can you post some docs about the "List" object or some source code if you have?
0
 
LVL 35

Accepted Solution

by:
girionis earned 200 total points
ID: 9850095
 Look here: http://j2medevices.com/documentation/midp1.0/javax/microedition/lcdui/List.html

  There are two types of constructors:

List(String title,  int listType)
          Creates a new, empty List, specifying its title and the type of the list.

List(String title, int listType, String[] stringElements, Image[] imageElements)
          Creates a new List, specifying its title, the type of the List, and an array of Strings and Images to be used as its initial contents.

   You need to change this:

NameSearchList = new List ("Name Search", List.IMPLICIT, resultSearch[0], null);

  to something that fits the constructors above. You probably want to use the second constructor but you are trying to pass an element as the third parameter instead of the array itself.

NameSearchList = new List ("Name Search", List.IMPLICIT, resultSearch[0], null);

  should probably be

NameSearchList = new List ("Name Search", List.IMPLICIT, resultSearch, null);

  in order to compile.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9850451
Yes.  Just drop the [0] from the resultSearch parameter.  The constructor needs an array of Strings.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 15

Expert Comment

by:jimmack
ID: 9850461
Just in case you need to, you are not doing a display.setCurrent() in setGetNameSearchList().
0
 

Author Comment

by:mdytz
ID: 9851303
It compiled, thank you for your help !!!
0
 
LVL 35

Expert Comment

by:girionis
ID: 9853442
:)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 48
oracle 11g 23 73
Configure a Bean in an XML file 4 31
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 31
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

813 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

16 Experts available now in Live!

Get 1:1 Help Now