Help Center

Local Navigation

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.
  1. Import the following classes:
    • net.rim.device.api.system.EncodedImage
    • net.rim.blackberry.api.messagelist.ApplicationIcon
    • net.rim.blackberry.api.messagelist.ApplicationMessageFolderRegistry
  2. Import the net.rim.blackberry.api.messagelist.ApplicationMessage interface.
  3. 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" ) );
    
  4. 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.