Setting the background color for my Blackberry application is very easy!

This is my screen:

final class GeneralExpenseViewScreen extends MainScreen {
    public GeneralExpenseViewScreen() {
        super();
        LabelField title = new LabelField("TeamMate TEC | Expenses",
                LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);

        Background bg = BackgroundFactory.createSolidBackground(0xBDBDDB);
        setBackground(bg);

        HorizontalFieldManager headerAreaManager = new HorizontalFieldManager();
        HorizontalFieldManager filterAreaManager = new HorizontalFieldManager();
        HorizontalFieldManager expenseListAreaManager = new HorizontalFieldManager();
        HorizontalFieldManager totalAreaManager = new HorizontalFieldManager();
        HorizontalFieldManager addNewAreaManager = new HorizontalFieldManager();

        add(headerAreaManager);
        add(filterAreaManager);
        add(expenseListAreaManager);
        add(totalAreaManager);
        add(addNewAreaManager);

        /**Begin form layouts**/

        Bitmap headerImage = Bitmap.getBitmapResource("sergioheader.png");
        BitmapField header = new BitmapField(headerImage);
        headerAreaManager.add(header);

    }

    public boolean onClose() {
        Dialog.alert("AH!");
        System.exit(0);
        return true;
    }
}

Note that I call setBackground directly on the class, but it does not work, as I think it will work.

How to set the background color in the form of my application?

Thank.

+5
source share
2 answers

I have successfully used this code:

protected void paint(Graphics graphics) {
    graphics.setBackgroundColor(0xBDBDDB);
    graphics.clear();
    super.paint(graphics);
}
+6
source

Depending on the version you are developing, you can use the following

getMainManager().setBackground(BackgroundFactory.createSolidBackground(Color.BLACK));

to set the background color for screen managers.

+5
source

All Articles