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

BlackBerry® World™ Development

Reply
Highlighted
Developer
Posts: 20
Registered: ‎06-22-2010
My Device: Bold
My Carrier: Telcel

setBackground not working

I am making a Java App with Blackberry JDE 5.0 on Eclipse plugin.

 

I have two questions:

 

First: I am trying to set a background on a MainScreen and  and I use:

 

setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("bg.png")));

 

The image is currently in the res folder and I have no problem adding it as a BitmapField, but it doesn't show if I set it as background.

 

Here is the complete class code:

 

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class SettingsScreen extends MainScreen{
    
    public SettingsScreen(){
        super();
        setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("bg.png")));
        setTitle("Propiedades");
       
        LabelField tf= new LabelField("");
        add(tf);
        tf.setText("test");
    }

}

 

 

Hope you can help me.

 

Thanks

Contributor
Posts: 24
Registered: ‎06-02-2010
My Device: Blackberry Curve 8900

Re: setBackground not working

you can use layout manager (horizontal or vertical ) to set background image.

you can use paint method of layout manager to set image.

 

also set image path to img/image_name.png.

img is a folder created inside res folder.