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: 157
Registered: ‎05-10-2009
My Device: Not Specified
Accepted Solution

theme colour

Hi,

 

I'm getting some user who use custom themes.  Their theme is black and I use some black images, so the images are not visible.  Is there a way to ensure a white background to all screens in my app?

 

Thanks,
macdan 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: theme colour

[ Edited ]

This is a common complaint. Once you paint ANYTHING, you run into the possibility of getting stepped on by the theme, unless you paint EVERYTHING.

 

The real problem here is not so much the theme, as the lack of any API for the app to detect and/or use the theme colors.

 

One "work-around" is to override the undocumented method "applyTheme" in your screen components (just an empty method). This should defeat the theme colors on your screen.

 

Signature for that method is

 

protected void applyTheme()

 

 

Message Edited by RexDoug on 09-12-2009 07:41 PM
Developer
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: theme colour

Thank you RexDoug.  I will give that a try.  It is great to hear from a Pro!
Developer
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: theme colour

I've added the empty method to my app's mainScreen, which overrides MainScreen.  It does not seem to defeat the theme.   Maybe I put it in the wrong place?  I see others on this forum overriding this method on derived popup screens but nothing about derived mainscreens
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: theme colour

Try using FullScreen instead of MainScreen.

 

 

 

 

 

Developer
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: theme colour

Thanks RexDoug.  I think the issue is that this user's theme (Ulterior BlackBerry Storm Theme) modifies the default background for all Apps to black.  I've tried to find other themes with the same behaviour but everything else seems to leave the default background alone.  I've purchased the offending theme, but can't get it to load on my storm simualtor (invalid cod files).  I think your solution will probably work, I just need to first reproduce the problem by finding a theme that modifies the background of all apps.  The good news is that changing background colours does not seem to be a widespread habit of theme creators (which unfortunately makes reprodction hard). Why anyone would make such a theme is baffling and why RIM allows this behavour is stranger still.   

 

Once I find another equally irritating theme and reproduce and verify, I'll report back and hopefully mark your post as the solution.

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: theme colour

In my experience, you can defeat the theme background by using FullScreen and setting the background yourself.

 

The issue is that you have to provide some the the "free stuff" you get with MainScreen, like a build-in VerticalFieldManager, etc.

 

Make sure you select the DEFAULT_MENU style in your constructor if you need the default system menu items.

 

 

Developer
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: theme colour

I think I can do that with a mainscreen subclass as well.

 

as per this KB article:

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

 

That is a different solutuion than defeating the theme by overrding applyTheme()

 

on 4.6 and above putting this in the constructor of the mainScreen child works fine:

 

_manager = (VerticalFieldManager)getMainManager();   

Background bg = BackgroundFactory.createSolidBackground(Color.WHITE);

_manager.setBackground(bg);

 

 The paint() override method described in the KB article for 4.5 and below didn't work so well.

 

I like your "applyTheme()" approach  as it seems more flexible as to work on all devices and all O.S. 4.2 and up - and it probaby works - it is just that I can't find a theme that changes the default background for all apps to test it.

Developer
Posts: 157
Registered: ‎05-10-2009
My Device: Not Specified

Re: theme colour

I found another  theme to test against and your solution works perfectly!!

 

In my mainScreen derived class, I put

protected void applyTheme()

{

 

}

 

and it defeats the theme's attempts to paint the background.

 

Thanks again RexDoug!!