Making the List of Hybrid Apps Searchable

Add a search field to the top of the Hybrid App list. 

Whenever the contents of the search field change, only Hybrid Apps with matching names are listed. The comment tag associated with this customization is BLACKBERRY_CUSTOMIZATION_POINT_HYBRIDAPPSEARCH.

  1. Open the AppScreen.java file for editing and add the following member variable to the AppScreen class:
    private String m_sSearchFor; 
  2. Add the following code in the constructor of AppScreen, before the line that says // Add list field to screen:
    //add in the search UI   
    LabelField searchLabel = new LabelField( "Search: " );   
    add( searchLabel );   
    EditField searchEdit = new EditField();   
    searchEdit.setChangeListener( new SearchFieldListener() );   
    add( searchEdit );       
    m_sSearchFor = ""; 
  3. Add the following code to the end of the populateList method:
    // BLACKBERRY_CUSTOMIZATION_POINT_HYBRIDAPPSEARCH   
    for (int i = 0; i < m_oApps.size(); i++) {   
       HybridApp ha = (HybridApp) m_oApps.elementAt(i);   
       if( m_sSearchFor == null || m_sSearchFor.equals("") || ha.getDisplayName().indexOf( m_sSearchFor ) >= 0 )   
       {   
          // there is no search, or this Hybrid App matches the search.   
          // do nothing since the Hybrid App is already in the list   
       }   
       else   
       {   
          // there is a search and this Hybrid App does not match   
          // remove this Hybrid App from the list   
          m_oApps.removeElementAt(i);   
          i--;   
       }   
    } 
  4. Add the following class to the AppScreen class:
    final class SearchFieldListener implements FieldChangeListener   
    {   
       public void fieldChanged( Field field, int context)   
       {   
          if( field instanceof EditField )   
          {   
             EditField oEditField = (EditField) field;   
             m_sSearchFor = oEditField.getText();   
             populateList();   
             updateScreen();   
          }   
       }   
    } 
  5. Open the CustomizationHelper.java file, which is located in the ...\HybridWebContainer\src\com\sybase\hwc folder and edit the getHybridAppScreenClass() method, to change the class returned to your new class.
    That class must extend Activity.
  6. Update the manifest.xml file to include the new activity you create.