View Single Post
Old 04-10-2008, 04:46 PM   #14
jfisher
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Default

to be honest i never found a good solid way of setting the background on a MainScreen, after talking with rim i'm 90% sure they'll add it to the api in future but for now... - i did need to do this for a project recently and the method i used might seem a little messy, but the code was actually much more elegant than trying to override field managers paint methods.

what i did was to keep track of each field added to the screen and increment a counter which gave me the total height in pixels used by the fields, if this was less than the height of the screen i added a custom spacerfield (Blackberry - SpacerField) to pad the rest. the app was built up with custom fields so i had control over the colours of each and worked dynamically with both pearl and 320x240 devices. but it feels like a hack so wouldn't want to blog about it, i'm sure other more experienced proto geeks could do it better, rim certainly did in their facebook app.

like everyone else, i'd love to see a nice working example including full source of setting the background colour of a MainScreen that doesn't cause more issues than it solves (it'd be a candidate for an article as this issues comes up every week it seems - i'm going to open up the dev lessons on northcubed to any other developers who want to contribute).

[edit - bwhelan's example looks elegant, i'll have to try it when i get a spare minute]
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!

Last edited by jfisher; 04-10-2008 at 04:48 PM..
Offline   Reply With Quote