Specify an icon in the EntityBasedSearchable or SearchableEntity class

Before you begin: Include a suitable graphic file for use as an icon in your project's resource folder. For more information about designing graphics for BlackBerry® devices, see UI Guidelines.
  1. Import the required classes.
    import net.rim.device.api.ui.image.Image;
    import net.rim.device.api.ui.image.ImageFactory;
    import net.rim.device.api.system.Bitmap;
  2. Create an instance variable to store the icon.
    private Image _icon;
  3. Import the graphic into your application from your resource folder.
    Bitmap img = Bitmap.getBitmapResource("icon.png")
  4. Check whether the import was successful, then create an icon.
    if(img != null) {
        _icon = ImageFactory.createImage(img);
    } else {
        _icon = null;
  5. In getIcon(), return the image.
    public Image getIcon() {
        return _icon;

Was this information helpful? Send us your comments.