BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-26-2009, 08:58 AM   #1
Morion
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
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, 09:54 AM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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, 10:07 AM   #3
Morion
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
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, 11:12 AM   #4
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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, 11:25 AM   #5
koic
Thumbs Must Hurt
 
Join Date: Feb 2009
Location: CANADA
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 64
Default

And be prepared to see some not pained paddings.
Offline  
Old 06-26-2009, 11:31 AM   #6
Morion
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
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, 01:19 PM   #7
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Post some code.
Offline  
Old 06-29-2009, 01:43 AM   #8
Morion
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
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, 05:18 AM   #9
Morion
Knows Where the Search Button Is
 
Join Date: Jun 2009
Location: Belarus, Minsk
Model: none
PIN: N/A
Carrier: none
Posts: 17
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5 picture

OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5

$14.63



Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M picture

Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M

$2.95



NEW VESA Adapter Plate for Dell E-Series Monitor - OEM picture

NEW VESA Adapter Plate for Dell E-Series Monitor - OEM

$8.50



Dell OEM Latitude Rugged Extreme 7404 Left and Right Mouse Buttons 00008 picture

Dell OEM Latitude Rugged Extreme 7404 Left and Right Mouse Buttons 00008

$5.95



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98



Dell 2400MP Audio Video Computer Projector OEM Lamp Part No: 0CF900 picture

Dell 2400MP Audio Video Computer Projector OEM Lamp Part No: 0CF900

$109.95







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