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
Contributor
Posts: 40
Registered: ‎10-10-2011
My Device: BB Curve&Bold
My Carrier: Airtel

How to create Badge in BB?

Hi All,

 

How to create a Badge in BlackBerry?Is it possible to create this, using paint method?

BlackBerry Development Advisor
Posts: 15,700
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to create Badge in BB?

Can you elaborate on what you are trying to do?  Are you trying to draw a picture of a badge?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: How to create Badge in BB?

[ Edited ]

Do you mean updating the icon with a notification badge? If so:

 

Icon sizing is a whole can of worms, but you'd create (at least) two different icons: your normal icon and your normal icon with a "badge" overlayed. These are two separate image files. Then, when you want your application to display the badge icon, you'd call:

 

HomeScreen.updateIcon(APP_ICON_BADGED, 0);

 Where APP_ICON_BADGED is the Bitmap resource of your badged icon:

 

public static final Bitmap APP_ICON_BADGED = Bitmap.getBitmapResource("images/icons/Icon_BADGE.png");
Contributor
Posts: 40
Registered: ‎10-10-2011
My Device: BB Curve&Bold
My Carrier: Airtel

Re: How to create Badge in BB?

Hi,

 

Thanks for your reply..you told to change the Home screen icon with some different BadgeImage.In my problem is ,create Badge icon in some other images (overlapping tha image),not Home screen.In Blackberry device application ,if new sms or call is coming ,the Badge icon is top on the message and call Icon in Home screen.Similar to inside the application how to create BadgeIcon on Image?I am trying in paint method but it is not looking good...

Contributor
Posts: 40
Registered: ‎10-10-2011
My Device: BB Curve&Bold
My Carrier: Airtel

Re: How to create Badge in BB?

yes.I am trying to draw a  Badge icon on Image.

 

forres = new BitmapField(res,FOCUSABLE){

forres = new BitmapField(res,FOCUSABLE){
			protected void drawFocus(Graphics _g, boolean _on) 
			 {
			      paint(_g);              
			      invalidate();
			 }
			 protected void paint(Graphics g) {
			  super.paint(g);
g.setColor(Color.RED);
g.drawArc(0, 2, 20, 20, 0, 360); 
 g.drawText("1", 0, 2);
			 }
		};

 I am using this..In draw text the value is dynamic.But its is not looking good..help me

 

BlackBerry Development Advisor
Posts: 15,700
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: How to create Badge in BB?

You shouldn't call paint directly.  Invalidate will trigger a call to paint of needed.  But you also shouldn't call invalidate in drawFocus, which could lead to an endless loop.

 

Here are some examples of custom fields that override paint and drawFocus that you could base your field off of.

 

http://supportforums.blackberry.com/t5/Java-Development/Create-a-scrollable-image-field/ta-p/444955

 

http://supportforums.blackberry.com/t5/Java-Development/Implement-advanced-buttons-fields-and-manage...

 

This example shows how to display focus changes in a BitmapField.

 

http://supportforums.blackberry.com/t5/Java-Development/Show-focus-changes-using-BitmapField/ta-p/44...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 33
Registered: ‎01-17-2013
My Device: DEVELOPER
My Carrier: DEVELOPER

Re: How to create Badge in BB?

Hey did u accomplish this using the native code ??
Is it possible to accomplish this using jquery ??

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to create Badge in BB?

[ Edited ]

Native code?  Are you talking BB10 - in which case you are in the wrong forum.   Choose the one that matches your development environment form this list:

http://supportforums.blackberry.com/t5/Application-Platforms/ct-p/app_plat

 

You are definitely in the wrong forum for JQuery.  Look at the list and ask the question in the WebWorks forum.

 

Good luck. 

New Developer
Posts: 33
Registered: ‎01-17-2013
My Device: DEVELOPER
My Carrier: DEVELOPER

Re: How to create Badge in BB?

Hi..I m facing the same problem now...can u give me your complete sample code from creating the icon till updating the icon with badge ,so that i ll try to implement that according to my requirements...

New Developer
Posts: 33
Registered: ‎01-17-2013
My Device: DEVELOPER
My Carrier: DEVELOPER

Re: How to create Badge in BB?

Hi..I m facing the same problem now...can u give me your complete sample code from creating the icon till updating the icon with badge ,so that i ll try to implement that according to my requirements...