1

I am having trouble changing the background color of Dialog from white to any color. I have tried the following code snippets but to no use.

dialog.getDialogStyle().setBgColor(0xffce78, true);
    dialog.getUnselectedStyle().setBgImage(Image.createImage("/main_bg.png"));
        dialog.getPressedStyle().setBgImage(Image.createImage("/main_bg.png"));
        dialog.getSelectedStyle().setBgImage(Image.createImage("/main_bg.png"));
SoH
  • 2,180
  • 2
  • 24
  • 53

2 Answers2

3

You need to use the dialog style getDialogStyle().

Regardless your code creates 3 separate yet identical images which is REALLY BAD! You are loading the same image 3 times into memory!

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I am doing all the three steps separately :) that is one at a time...i just wrote them all in once to show I have tried each one of them with no results :) – SoH Jun 09 '12 at 20:01
  • I don't see among your options setting the background image for the dialog style. Its the only one that will work. If you use an existing theme take into consideration that the dialog might have a border or style behavior you will need to override so color might not be enough. – Shai Almog Jun 13 '12 at 18:17
0

Is you image in the root directory? You should use the full path from the src folder, I mean, if your image is in the "images" package, you should put this path "/images/main_bg.png". If it is in the default package...."main_bg.png"

Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • I have kept all the images in the res folder and have been using them perfectly. This is the only occasion where this has not worked. Even if i dont not use images (for instance in the first line of code) i hvae set the image bg color, still the background of dialog shows white – SoH Jun 07 '12 at 11:41