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: 113
Registered: ‎04-09-2009
My Device: Not Specified
Accepted Solution

How to load Themes/Images?

[ Edited ]

Hello,

 1)  How do I Theme or Background Image for my application?

 2) How do I display image by reading bytes or directly reading from a image file?

 

 

Any sample source would be really helpful.

 

Thanks in advance..

 

Regards,

-Dillip

 

 

Message Edited by dkumar on 04-09-2009 02:36 PM
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: How to load Themes/Images?

Hi,

 

You can set background in your appliction by using below mentioned code

VerticalFieldManager _manager = (VerticalFieldManager)getMainManager(); Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("Blank.png")); _manager.setBackground(bg); add(_manager);

But this will work only for version 4.7 as this API (Background and BackgroundFactory)  are provided with this version only.

 

You can display image by using BitmapField.

  

Below is the code for the same

Bitmap objBitmap = Bitmap.getBitmapResource("Back.png"); BitmapField objHeader = new BitmapField(objBitmap); setTitle(BitmapField);

Please let me know this helped you or not.

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 113
Registered: ‎04-09-2009
My Device: Not Specified

Re: How to load Themes/Images?

Hi Rajat,

   Thanks for your prompt response. I'll try this out and let you know.

 

 

Regards,

-Dillip

 

Developer
Posts: 113
Registered: ‎04-09-2009
My Device: Not Specified

Re: How to load Themes/Images?

Hi Rajat,

  I get below error when I try to run the the app.

 

Uncaught Exception: java.lang.illegalArgumentException.

 

Here is the code I have put inside the constructor of Screen Class:

 

  VerticalFieldManager _manager = (VerticalFieldManager)getMainManager();
          Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("back.PNG"));
          _manager.setBackground(bg);

            add(_manager);

 

Am I missing anything?

 

Thanks,

-Dillip

Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: How to load Themes/Images?

class LoginScreen extends MainScreen { //Manager private VerticalFieldManager _manager; LoginScreen() { //Set Background image _manager = (VerticalFieldManager)getMainManager(); Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("back.png")); _manager.setBackground(bg); } }

 

and add resource back.png into your project.

 

Please let me know whether you where able to run it or not

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Posts: 113
Registered: ‎04-09-2009
My Device: Not Specified

Re: How to load Themes/Images?

Hi Rajat,

   Thanks for your help.  Now it works fine.  Is there any way, where we can stretch/squeeze the image according to the screen size?

 

 

One more question:

   How do we use/load a THEME for an application programmatically?

 

Thanks again..

 

Regards,

-Dillip

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

Re: How to load Themes/Images?

You can resize an image by using the EncodedImage.scaleImage32 method.  There is no way to programmatically interact with a theme.
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
Highlighted
New Developer
Posts: 4
Registered: ‎06-24-2009
My Device: Not Specified

How do i display image?

hi, 

 

     i wrote code like this 

 

        Bitmap img=Bitmap.getBitmapResource("alone_full.png");
        BitmapField imgF=new BitmapField(img);
        add(imgF);

 

    image was not displaying for me and i am getting error like

  

    FEDGE : could not found alone_full.png

 

can anyone give me solutions for this.. and how to make image to be displayed?

New Developer
Posts: 4
Registered: ‎06-24-2009
My Device: Not Specified

Re: How do i display image?

hi, i wrote code like this

 

 

   Bitmap img=Bitmap.getBitmapResource("alone_full.png");

   BitmapField imgF=new BitmapField(img);

   add(imgF);

   image was not displaying for me and i am getting error like

  

     FRIDG: could not found alone_full.png

 

       can anyone give me solutions for this.. and how to make image to be displayed?

New Developer
Posts: 4
Registered: ‎06-24-2009
My Device: Not Specified

Re: How do i display image?

hi, i wrote code like this

 

 

   Bitmap img=Bitmap.getBitmapResource("alone_full.png");

   BitmapField imgF=new BitmapField(img);

   add(imgF);

   image was not displaying for me and i am getting error like

  

     FRIDG: could not found alone_full.png

 

       can anyone give me solutions for this.. and how to make image to be displayed?