views:

227

answers:

1

I'm writing a BlackBerry app in Java using the BlackBerry Java API (OS 4.7 and above). I would like to add an icon to the title row of my app. The API documentation says that the method "setTitle" of the "MainScreen" class takes a "Field", so I thought I could just create a "HorizontalFieldManager" that contains an icon (BitmapField) and some text (LabelField). However when I do that I get a weird exception. Is it possible at all to use any field (other than LabelField) for setTitle()?. I've seen that other apps have icons in their title row, but maybe they're not using setTitle() but create their own (fake) title row.

+1  A: 

I already solved it. I don't know what I did wrong previously, but this is how it works as I described it in the initial question:

HorizontalFieldManager manager = new HorizontalFieldManager();
BitmapField bitmap = new BitmapField(PNGEncodedImage.getEncodedImageResource("icon.png").getBitmap());
LabelField label = new LabelField(text);

manager.add(bitmap);
manager.add(label);

setTitle(manager);
jkramer