Sending message to multiple contacts of mobile by providing search facility in J2ME
I wan to send the message to multiple contacts in the contactlist
list=new List("Select Contacts", List.MULTIPLE);
int n=list.getFitPolicy();
list.setTicker(ticker);
contactmanipulation.getContactData(vector);
for(int j=0;j<vector.size();j++){
listofContacts=new ListofContacts();
listofContacts=(ListofContacts)vector.elementAt(j);
list.setFitPolicy(1);
list.append(listofContacts.contactname + " "+ listofContacts.contactno,null);
}
list.addCommand(ok);
list.addCommand(cancel);
list.setCommandListener(this);
display.setCurrent(list);
here开发者_开发问答 i have taken all the contacts of contact list in vector and the listofcontacts is the class containing the name and number. To show the list of contacts for selection i am using list control with multiple choice.
The code is working fine and message is sent to all the contacts which are selected by the user but as we know there may be 1000 of contacts in phonebook and in these case to select a particular user we have to scroll down the list. Now how to keep the search facility so that we can directly go to the required contact and if it is not possible with the list control which control is to be used so that multiple contacts can be selected and also search facility is available.
This is typically the kind of thing you will find hard to do using only the standard basic LCDUI controls.
Basically, you want to keep your multi-selectable List
but add a TextField
to the screen. When the user inputs characters into the text field, contacts are removed from the List
when neither their first name nor their last name begin with the user input.
The text field is entirely doable but you need to use a Form
as your main screen, not a List
.
You can either let the user go back and forth between the 2 screens (the search input Form
and the updated contact List
with the result of the search) or you need to convert your whole List
to a Form
by creating your own subclass of CustomItem
to display each item in the list and write the code to deal with item selection by yourself.
I would suggest looking into LWUIT as that may provide a simpler solution.
精彩评论