Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel
Accepted Solution

Is it possible to add Badge in Blackberry?

Hi

I want to add extra information (like number) on several images,

which could be done easily by adding badges to it.

Is it possible to add Badge on image in Blackberry app??

If no, could anyone please suggest another way perform the task

 

Regards,

Developer
Posts: 16,679
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Is it possible to add Badge in Blackberry?

you can use the graphics class to draw text directly on the image or on one of the containers (like the screen).

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel

Re: Is it possible to add Badge in Blackberry?

Hi Simon

I tried drawing text on image using Graphics class and paint method

problem is that it draws at the background and not in the front of the image

Is it possible to draw something like text in front of image??

Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: Is it possible to add Badge in Blackberry?

Simon gave real advise how to do that. Sound that you are using method in wrong order. Can you draw badges after image drawing?
Developer
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel

Re: Is it possible to add Badge in Blackberry?

Hi Eugen

Thnx for Quick reply

Might be i am using graphics class in wrong way.. please have look at my code

 

 

Bitmap bit = Bitmap.getBitmapResource("bit.png");
_bitmapField = new MyBitmapField(bit,BitmapField.FOCUSABLE){ public void paint(Graphics g){ g.setColor(Color.RED); g.fillArc(33, 2, 17, 17, 0, 360); g.setColor(Color.WHITE); g.setFont(badgeFont); g.drawText("12", 37, 3); super.paint(g); } };

 Here _bitmapField is customBitmapField which can act as a button

please tell me where i am doing wrong ??

 

Developer
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE
My Carrier: Vodafone NL

Re: Is it possible to add Badge in Blackberry?

Call super.paint() at beginning of the overrided method and after put your code.

Developer
Posts: 53
Registered: ‎01-12-2011
My Device: BOLD 9780
My Carrier: Bharti Airtel

Re: Is it possible to add Badge in Blackberry?

Yup its working fine

Thanx Eugen and Simon