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 );
Create a custom folder in the message list
To be able to perform operations on custom messages, the BlackBerry® device application must register at least one custom
folder.
1.
Import the following classes:
•
net.rim.blackberry.api.messagelist.ApplicationMessageFolderRegistry
•
net.rim.blackberry.api.messagelist.ApplicationMessageFolder
2.
Import the following interfaces:
•
net.rim.blackberry.api.messagelist.ApplicationMessage
•
net.rim.device.api.collection.ReadableList
•
net.rim.blackberry.api.messagelist.ApplicationMessageFolderListener
3.
Create a class that implements the
ApplicationMessage
interface.
public class MLSampleMessage implements ApplicationMessage
4.
Obtain a reference to the
ApplicationMessageFolderRegistry
.
ApplicationMessageFolderRegistry reg =
ApplicationMessageFolderRegistry.getInstance();
5.
Register an BlackBerrydevice application folder for each collection of messages.
ReadableList inboxMessages = messages.getInboxMessages(); // collection
with MLSampleMessage elements
ReadableList deletedMessages = messages.getDeletedMessages(); //
collection with MLSampleMessage elements
ApplicationMessageFolder inboxFolder = reg.registerFolder
Development Guide
Create a custom folder in the message list
72