I have code that work fine but unexpectedly work slow in blackberry device
public ContactsScreen()//(Object _app)
{
setTitle(new LabelField( "Contac开发者_Python百科ts",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
//_contactNamesVector = new Vector();
_contactVector = new Vector();
_contacts = getContactListInVector();
//ReadableList _readableList =(ReadableList) _contacts;
if(_contacts != null)
{
// Create an instance of our SortedReadableList class.
//it takes _contacts as vector and then sort it accordingly
_contactSortedList = new ContactSortedList(_contacts);
// Add our list to a KeywordFilterField object.
_keywordFilterField = new KeywordFilterField()
{
protected boolean navigationClick(int status,int time)
{
int index = getSelectedIndex();
//Return data in redableklist format ie collectionlist and boolean
ContactInfo data = (ContactInfo)getSelectedElement();
data.toggleChecked();
invalidate(index);
if(data.isChecked())
{
// UiApplication.getUiApplication().popScreen(getScreen());
data.displayMultipleContacts();
//String str1 = data.getCompanyName();
//Dialog.alert(str1);
//String str2 = data.getFirstName();
//Dialog.alert(str2);
//String str3 = data.getLastName();
//Dialog.alert(str3);
//String str4 = str1.concat(str2).concat(str3);
}
return true;
}
// public boolean keyChar(char key, int status, int time){
// if(key == Keypad.KEY_ENTER){
// int index = getSelectedIndex();
// //Return data in redableklist format ie collectionlist and boolean
// ContactInfo data = (ContactInfo)getSelectedElement();
// data.toggleChecked();
// invalidate(index);
// if(data.isChecked())
// {
// // UiApplication.getUiApplication().popScreen(getScreen());
// data.displayMultipleContacts();
//
// //String str1 = data.getCompanyName();
// //Dialog.alert(str1);
// //String str2 = data.getFirstName();
// //Dialog.alert(str2);
// //String str3 = data.getLastName();
// //Dialog.alert(str3);
// //String str4 = str1.concat(str2).concat(str3);
//
// }
//
// }
// if(key == Keypad.KEY_ESCAPE){
// UiApplication.getUiApplication().popScreen(getScreen());
//
// }
// return true;
// }
};
_keywordFilterField.setSourceList(_contactSortedList,_contactSortedList);
//register keywordfield with Callbackinterface list display, it call methods of callback
_keywordFilterField.setCallback(_contactSortedList);
_contactSortedList.setReadableList(_keywordFilterField.getResultList());
// We're providing a customized edit field for
// the KeywordFilterField.
CustomKeywordField customSearchField = new CustomKeywordField();
_keywordFilterField.setKeywordField(customSearchField);
// We need to explicitly add the search/title field via MainScreen.setTitle().
this.setTitle(_keywordFilterField.getKeywordField());
// Add our KeywordFilterField to the screen and push the screen
// onto the stack.
this.add(_keywordFilterField);
}
}
精彩评论