Create an icon for a custom message
You can associate an icon with a message. In the message list, the icon displays on the left side of a message.
- Import the following classes:
- net.rim.device.api.system.EncodedImage
- net.rim.blackberry.api.messagelist.ApplicationIcon
- net.rim.blackberry.api.messagelist.ApplicationMessageFolderRegistry
- Import the net.rim.blackberry.api.messagelist.ApplicationMessage interface.
- To create an icon based on an encoded image, when you create an instance of an ApplicationIcon, invoke EncodedImage.getEncodedImageResource with the name of the image file as an argument.
ApplicationIcon newIcon = new ApplicationIcon( EncodedImage.getEncodedImageResource( "ml_sample_new.png" ) );
ApplicationIcon openedIcon = new ApplicationIcon( EncodedImage.getEncodedImageResource( "ml_sample_opened.png" ) );
- To assign a status and an icon to a message, invoke ApplicationMessageFolderRegistry.registerMessageIcon and specify the following as parameters: a value for the message type for an BlackBerry®device application, a field from the ApplicationMessage.Status interface as the status argument, and an instance of an ApplicationIcon.
int MESSAGE_TYPE = 0;
reg.registerMessageIcon( MESSAGE_TYPE, STATUS_NEW, newIcon );
reg.registerMessageIcon( MESSAGE_TYPE, STATUS_OPENED, openedIcon );
Index
Was this information helpful? Send us your comments.