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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha
Accepted Solution

Bitmap is not displayed

Hi,

 

I am using following code, there is no exception and err throw, label is displayed on the screen but Bitmap is not visible... Am i missing something...? Plz. help

 

 private class AboutScreen extends MainScreen
          {
              
                private Bitmap backgroundBitmap;
                private Bitmap fieldBitmap;
 
                public AboutScreen()
                {
                   
                    this.setTitle("About App");
                    backgroundBitmap = Bitmap.getBitmapResource("logo.png");
                    System.out.println("Width = "+backgroundBitmap.getWidth()+ "\nheight = "+backgroundBitmap.getHeight());
                    vfm = new VerticalFieldManager(VerticalFieldManager.NO_HORIZONTAL_SCROLL | VerticalFieldManager.NO_VERTICAL_SCROLL);
                    hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)
                    {
                        public void paint(Graphics graphics)
                        {
                            graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
                            super.paint(graphics);
                        }           
                    };
                   
                    hfm_2 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
                   
                    s = "This is a label, I want it at the bottom of this Screen";
                    style =  LabelField.USE_ALL_WIDTH | LabelField.FIELD_BOTTOM;
                   
                    lbl_hdr =  new LabelField(s,style)
                    {
                            protected void layout( int maxWidth, int maxHeight )
                            {
                                    int displayWidth = 500; // As reference
                                    int displayHeight = 120; // as reference
                                    super.layout( displayWidth, displayHeight);
                                    setExtent( displayWidth, displayHeight );
                            }                       
                     };
                    hfm_2.add(lbl_hdr);
                    vfm.add(hfm_1);
                    vfm.add(hfm_2);
                    add(vfm);
                }
               
               protected boolean onSavePrompt()
               {
                    return true;
               }
 
         
          } 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Bitmap is not displayed

Your HorizontalFieldManager hfm_1  has no Fields in it, so has no need for any screen space, so no need to draw the background image. 

 

I suggest that you use the paint menthod you have for the hfm_1 in the AboutScreen, i.e. overrride the AboutScreen paint method and don't use hfm_1 at all.

Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Bitmap is not displayed

Hi Peter,

 

Thnx for the response..

 

Well, I would try as you suggestedto override the AboutScreen paint method and not using hfm_1 at all. But, I have gone thru KB article

           

                 http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

 

And, in the same manner I am trying to create a background image for my application... Is somethng wrong in using it..?

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Highlighted
Developer
Posts: 209
Registered: ‎11-08-2008
My Device: Not Specified

Re: Bitmap is not displayed

 

Try to do like this,

 

 HorizontalFieldManager hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)
                    {

                        int width = 50;
                        int height = 50;


                        protected void sublayout(int width, int height)
                        {

                            width = this.width;

                            height = this.height;
                            super.setExtent(width,height);
                                               
                        }


                        public void paint(Graphics graphics)
                        {
                            graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
                            super.paint(graphics);
                        }          
                    };

Thanks and Regards
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Bitmap is not displayed

Thnx Mudassir, it worked...

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro