Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

J2ME lcdui.List problem

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
mdytz
Asked:
mdytz
  • 3
  • 2
1 Solution
 
girionisCommented:
> 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
 
girionisCommented:
 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
 
jimmackCommented:
Yes.  Just drop the [0] from the resultSearch parameter.  The constructor needs an array of Strings.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jimmackCommented:
Just in case you need to, you are not doing a display.setCurrent() in setGetNameSearchList().
0
 
mdytzAuthor Commented:
It compiled, thank you for your help !!!
0
 
girionisCommented:
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now