BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 06-26-2009, 09:58 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down trouble with background

Please Login to Remove!

I want to have a background in my app. Here is the code.
Code:
	
private void createUI(){
		backGround = Bitmap.getBitmapResource("bg.jpg");
		myManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR){
			public void paint(Graphics graphics){
				graphics.clear();
				graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backGround, 0, 0);
				super.paint(graphics);
			}
		};
		
		add(myManager);
	}
In the debug mode i see, that backGround is not null. But i cannot see my background picture on the display of simulator. Any ideas?

P.S. I use Eclipse. And please, dont tell me about Background class. I want to do it using 4.5.0 APIs.
Offline  
Old 06-26-2009, 10:54 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Are you adding any fields to the manager? If not, the extent of the manager is 0,0 and you will not see your background.

Did you try the Screen.paintBackground() method?
Offline  
Old 06-26-2009, 11:07 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmm... Thanks for advice. I tried to add a LabelField. Part of my background image appears only under this field. Is there any way to draw only background picture without adding elements?
Offline  
Old 06-26-2009, 12:12 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Not with Manager. You'll need to paint the background on the screen, as I indicated in the previous post. What you are seing is expected behavior, since the manager adaptes it's extent to the extent of the field(s).

Another possibility is to add the background as a BitmapField, then paint over the background in the paint() method of the screen.

It all depends on what you are trying to accomplish.
Offline  
Old 06-26-2009, 12:25 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

And be prepared to see some not pained paddings.
Offline  
Old 06-26-2009, 12:31 PM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to make a static background in application. And i've just tried to override paintBackground() and pain() methods for my screen. Result - thin line of my background image at the top of the screen. When i added a LabelField to my screen, it appears after this thin line with default white background.
Offline  
Old 06-26-2009, 02:19 PM   #7 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Post some code.
Offline  
Old 06-29-2009, 02:43 AM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, sorry for late post. Here's my code.
Code:
public class Screen extends MainScreen{
	private Bitmap backGround; 
	
	public Screen(){
		super(NO_VERTICAL_SCROLL);
		setTitle("This is a test");
		createUI();
	}
	
	private void createUI(){
		backGround = Bitmap.getBitmapResource("bg.jpg");
	        add(new LabelField("YO!", USE_ALL_WIDTH ));
	}

	protected void paintBackground(Graphics graphics){
		graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backGround, 0, 0);
		super.paintBackground(graphics);
	}
	
	
//	protected void paint(Graphics graphics){
//		super.paint(graphics);
//	}

	public boolean onClose(){
		Dialog.alert("Bye!");
		System.exit(1);
		return true;
	}
Offline  
Old 06-29-2009, 06:18 AM   #9 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yahoo! I've just made this. Here's code.
Code:
	private void createUI(){
		backGround = Bitmap.getBitmapResource("bg.jpg");
		myManager = new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR){
			public void paint(Graphics graphics){
				graphics.clear();
				graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(), backGround, 0, 0);
				super.paint(graphics);
			}
		};
		
		mainManager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR){
			protected void sublayout(int maxWidth, int maxHeight){
				int displayWidth = deviceWidth;
				int displayHeight = deviceHeight;
				
				super.sublayout(displayWidth, displayHeight);
				setExtent(displayWidth, displayHeight);
			}
		};
		
		myManager.add(mainManager);
		add(myManager);
		
	}
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.