Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
praveena
Posts: 8
Registered: ‎07-15-2010
My Device: 1.0

Search option working in Blackberry storm 8300 but it's not working in BB storm 9530

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();
    }

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Search option working in Blackberry storm 8300 but it's not working in BB storm 9530

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
praveena
Posts: 8
Registered: ‎07-15-2010
My Device: 1.0

Re: Search option working in Blackberry storm 8300 but it's not working in BB storm 9530

 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();
    }

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Search option working in Blackberry storm 8300 but it's not working in BB storm 9530

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?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker