0

This is my code for selecting the contact number from the phonebook. I'm able to search and select the contact number from the mobile phone contact list. But, I want to select multiple contacts and add them in the textfield.

tb2 = new TextField("To: ", "", 30, TextField.PHONENUMBER);
            tb3 = new TextField("Message: ", "", 300, TextField.ANY);
            form1.append(tb2);
            form1.append(tb3);

            form1.addCommand(submitCommand);
            //display.setCurrent(tb3);
            display.setCurrent(form1);
gnat
  • 6,213
  • 108
  • 53
  • 73

2 Answers2

1

When you use PHONENUMBER constraint only one phone number should be present. According to the API:

"A PHONENUMBER field might be displayed with digit separators and punctuation as appropriate for the phone number conventions in use, grouping the digits into country code, area code, prefix, etc. Any spaces or punctuation provided are not considered part of the text object's actual contents. For example, a text object with the PHONENUMBER constraint might display as follows: "(408) 555-1212", but the actual contents of the object visible to the application through the APIs would be the string "4085551212"."

I think you should try using a ChoiceGroup with MULTIPLE type instead.

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
  • any demo/example, which i can refer.. ?? –  May 16 '12 at 11:22
  • Take a look at http://www.java-tips.org/java-me-tips/midp/how-to-use-choicegroup-in-j2me.html In your case you will call append with the phone numbers. – Telmo Pimentel Mota May 16 '12 at 11:25
  • i don't think so... it would be helpful for my case. BuT, let me try first –  May 16 '12 at 11:31
  • it is not helpful for me, because, once i change the textfield into choicegroup, then i'm unable to access the phonebook contact list. and which means no use of using choicegroup –  May 16 '12 at 11:34
  • You could access the phonebook manually using PIM API and create the choicegroup entries. – Telmo Pimentel Mota May 17 '12 at 11:38
  • How is that..?? any example.. ? –  May 17 '12 at 15:49
  • Start reading this series on PIM: http://developers.sun.com/mobility/apis/pim/pim1/ http://developers.sun.com/mobility/apis/pim/pim2/ http://developers.sun.com/mobility/apis/pim/pim3/ http://developers.sun.com/mobility/apis/pim/pim4/ http://developers.sun.com/mobility/apis/pim/pim5/ – Telmo Pimentel Mota May 18 '12 at 11:34
-1

What's the problem?

    /**
     *@param current - your current TextField String
     */
    public String addContact(String current) {
        return current += "," + getNextContact();
    }

    public String getNextContact() {
        //here should be the code that gives you single one
    }
Yaroslav Mytkalyk
  • 16,950
  • 10
  • 72
  • 99
  • can you please elaborate with my code, i mean how and where can i use your code into my code for selecting multiple contact list. Thanks in advance !! –  May 16 '12 at 10:46
  • I thought you need to append several contact numbers to TextField. It is hard for me to understand what do you mean from your first post. – Yaroslav Mytkalyk May 16 '12 at 16:04