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
Highlighted
Contributor
Posts: 20
Registered: ‎05-17-2012
My Device: have no device
My Carrier: KievStar
Accepted Solution

Adding image problem...

I did tried add image to MyAppScreen

 

public class MyAppScreen extends MainScreen {

}

 

and a found this code on the BlackBerry developer site

 

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;

public class DisplayAnImage extends MIDlet
{
    private Form mForm;
    private Display mDisplay;
    private Image pngBackground;
    
    public DisplayAnImage()
    {
    }
    
    public void destroyApp(boolean flag)
    {
    }
    
    public void startApp()
    {
            mDisplay = Display.getDisplay(this);
            mForm = new Form("MIDlet Developer Guide: Display an image.");
            
            try
            {
                pngBackground = Image.createImage("test_image.png");
                ImageItem img = new ImageItem("bg",pngBackground,
                ImageItem.LAYOUT_EXPAND,"background"); 
                mForm.append(img); 
                mDisplay.setCurrent(mForm); 
            }
            catch(IOException e)
            {
                System.out.println(e.getMessage());
            }
    }
    
    public void pauseApp()
    {
    }
}
QUestion! How i can display image with this code ... Or can you give me other advice for display image?.. 
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Adding image problem...

this code is a j2me code, not a blackberry code.

use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/component/BitmapField.html to display an image, and http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/Bitmap.html#getBitmapRe... to read it fropm your resource folder.
----------------------------------------------------------
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
New Developer
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: Adding image problem...

Hi,

what kind of image do you want to add? Something like a logo? or you want to show the whole pic in the screen?

New Developer
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: Adding image problem...