07-28-2010 07:31 AM
Hi,
i have 4000 records i want to search some of the records By Name and By Number these two are my options, i was used bellow code it's working in BB 8300 simulator and not working in 9530 what the problem i didn't find that problem . plz any one replay me
textName is the given name, text is the record
private void byNameAction() {
final FieldChangeListener fListener = this;
final String textName = editField.getText().trim().toLowerCase();
Runnable listLoader = new Runnable() {
private UiApplication app = UiApplication.getUiApplication();
public void run() {
editField.setEditable(false);
for (int i = 0; i < elements.size(); i++) {
ICD10Info info = (ICD10Info) elements.elementAt(i);
String text = info.getName().trim().toLowerCase();
if((text.length() > editField.getText().trim().length())){
text = text.substring(0, textName.length());
}
if(text.equalsIgnoreCase(textName)){
info.setListHeight(35);
final CustomListField listItemField = new CustomListField(
info, false, true, "", false, "");
listItemField.setCookie(info);
synchronized (Application.getEventLock()) {
vManager.add(listItemField);
}
listItemField.setChangeListener(fListener);
}
}
if (vManager.getFieldCount() == 0 || editField.getText().trim().equals("")) {
synchronized (Application.getEventLock()) {
vManager
.add(new RichTextField("No Diseases found"));
}
} else {
app.invokeAndWait(new Runnable(){
public void run() {
Status.show("Search completed.");
}
});
}
editField.setEditable(true);
}
};
new Thread(listLoader).start();
}
07-28-2010 01:03 PM
Can you elaborate on what is not working? If an error or exception is shown, what is it? What line of code is triggering the error?
What BlackBerry device software version are you testing on? You can find this under Options, About on the BlackBerry Smartphone.
07-29-2010 07:49 AM
Hi,
i was used search class for seach names and codes (Like this name :Neoplasams and code:A20 ) i was entered (Neo) in input textField, related names are displayed in 8300 Simulator and also in 9530 BB simulator when ever install in real device (9530) it's not working means when ever click search by name button no data displayed. it's working in real device (8300 BB simulator).
for increasing the speed of search i was used Thread (see the bellow code). with out threads it's working in real device (9530 is the touch Phone and also in 8300 non touch ) what the problem with threads i con't understand please tell me
textName is the given name, text is the name(what ever in a record), elements.size is the 4000 records, vManager is the VerticalFieldManager
when ever click SearchByName Button this method is working
private void byNameAction() {
final FieldChangeListener fListener = this;
final String textName = editField.getText().trim().toLowerCase();
Runnable listLoader = new Runnable() {
private UiApplication app = UiApplication.getUiApplication();
public void run() {
editField.setEditable(false);
for (int i = 0; i < elements.size(); i++) {
ICD10Info info = (ICD10Info) elements.elementAt(i);
String text = info.getName().trim().toLowerCase();
if((text.length() > editField.getText().trim().length())){
text = text.substring(0, textName.length());
}
if(text.equalsIgnoreCase(textName)){
info.setListHeight(35);
final CustomListField listItemField = new CustomListField(
info, false, true, "", false, "");
listItemField.setCookie(info);
synchronized (Application.getEventLock()) {
vManager.add(listItemField);
}
listItemField.setChangeListener(fListener);
}
}
if (vManager.getFieldCount() == 0 || editField.getText().trim().equals("")) {
synchronized (Application.getEventLock()) {
vManager
.add(new RichTextField("No Diseases found"));
}
} else {
app.invokeAndWait(new Runnable(){
public void run() {
Status.show("Search completed.");
}
});
}
editField.setEditable(true);
}
};
new Thread(listLoader).start();
}
07-29-2010 09:04 AM
Where are you pushing the screen onto the display stack? If it has already been displayed before your thread completes will need to call invalidate on the screen to have it redraw itself. Otherwise it may be displayed before you have added all of your records.
Have you tried connecting the BlackBerry Smartphone to Eclipse and step through your code to see how the behaviour differs? If so, do you see any error or exception?