Create an icon for a custom message
You can associate
icons with a custom message. You associate an icon with a custom message's type
and status. For example, you can associate one icon with an unopened message
and a different icon with an opened message. The icon appears on the left side
of a message in the Messages application.
-
Import the required classes and interfaces.
import net.rim.blackberry.api.messagelist.*;
import net.rim.device.api.system.EncodedImage;
-
Invoke
EncodedImage.getEncodedImageResource() to create an
icon based on an encoded image. Pass in the file name as an argument.
ApplicationIcon newIcon =
new ApplicationIcon( EncodedImage.getEncodedImageResource( "ml_sample_new.png" ) );
ApplicationIcon openedIcon =
new ApplicationIcon( EncodedImage.getEncodedImageResource( "ml_sample_opened.png" ) );
-
Invoke
ApplicationMessageFolderRegistry.registerMessageIcon()
to assign a status and an icon to a custom message. Specify the following as
arguments: a value for the message type for a
BlackBerry®
device application, a message status by using a field from the
ApplicationMessage.Status interface, and an instance
of the
ApplicationIcon class.
int MESSAGE_TYPE = 0;
int STATUS_NEW = ApplicationMessage.Status.UNOPENED;
int STATUS_OPENED = ApplicationMessage.Status.OPENED;
reg.registerMessageIcon( MESSAGE_TYPE, STATUS_NEW, newIcon );
reg.registerMessageIcon( MESSAGE_TYPE, STATUS_OPENED, openedIcon );
Was this information helpful? Send us your comments.