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.
-
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;
-
Create an instance variable to store the icon.
private Image _icon;
-
Import the graphic into your application from your resource
folder.
Bitmap img = Bitmap.getBitmapResource("icon.png")
-
Check whether the import was successful, then create an icon.
if(img != null) {
_icon = ImageFactory.createImage(img);
} else {
_icon = null;
}
-
In
getIcon(), return the image.
public Image getIcon() {
return _icon;
}
Was this information helpful? Send us your comments.