BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 02-16-2010, 06:48 PM   #1 (permalink)
New Member
 
Join Date: Feb 2010
Model: 8320
PIN: N/A
Carrier: T-Mobile
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem adding BitmapField to screen

Please Login to Remove!

I am trying to add a bitmap field to a layout and the bitmap field does not show up. Conceptually, this is what I am trying to achieve:

MainScreen - has a two label fields and a HorizontalFieldManager, hfm with vertical scrolling
hfm contains two VerticalFieldManagers, vfm_left and vfm_right
vfm_left contains two labels, left_1 and left_2
vfm_right has horizontal scrolling
vfm_right contains two images, about 60 px X 60 px each
I have attached a wire frame that might be easier to understand.

Here is the code:
Code:
public class LayoutScreen extends MainScreen{
    public LayoutScreen() {
    super(VerticalFieldManager.USE_ALL_WIDTH | 
	 VerticalFieldManager.USE_ALL_HEIGHT | 
	 VerticalFieldManager.NO_VERTICAL_SCROLL);
		
    LabelField title = new LabelField("title and background");
    LabelField score = new LabelField("score");
    add(title);
    add(score);
		
    HorizontalFieldManager hfm = new HorizontalFieldManager(
	HorizontalFieldManager.USE_ALL_WIDTH | 
	HorizontalFieldManager.USE_ALL_HEIGHT | 
	HorizontalFieldManager.VERTICAL_SCROLL | HorizontalFieldManager.VERTICAL_SCROLLBAR);
		
    VerticalFieldManager vfm_left = new VerticalFieldManager();
    LabelField left_1 = new LabelField("left 1");
    LabelField left_2 = new LabelField("left 2");
    vfm_left.add(left_1);
    vfm_left.add(left_2);
		
    VerticalFieldManager vfm_right = new VerticalFieldManager(
           HORIZONTAL_SCROLL | HORIZONTAL_SCROLLBAR);
        
    BitmapField image_1 = new   BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );

    BitmapField image_2 = new BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );
		
    vfm_right.add(image_1);
    vfm_right.add(image_2);
		
    hfm.add(vfm_left);
    hfm.add(vfm_right);	
		
    add(hfm);
}
The BB emulator (8320 T-Mobile) only shows the labels and no images. I have attached a screen shot from the emulator.

What am I missing?

Thanks,

Mark
Attached Images
File Type: png wireframe.png (17.4 KB, 17 views)
File Type: png Screenshot.png (8.3 KB, 14 views)
Offline  
Old 02-16-2010, 07:41 PM   #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

The default behavior of the labels is "take all available width".

You need to overide this behavior.
Offline  
Old 02-16-2010, 08:06 PM   #3 (permalink)
New Member
 
Join Date: Feb 2010
Model: 8320
PIN: N/A
Carrier: T-Mobile
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh.....how do I do "override this behavior"? Should I put the label in a separate FieldManager? Or, do I have to create a custom label and override some methods? What methods?

BTW, I just tried a test where I did not add the labels to vfm_left, but I added bitmaps, and no bitmaps are displayed. Here is the modified code:

Code:
public class LayoutScreen extends MainScreen{
	
	    public LayoutScreen() {
	    super(VerticalFieldManager.USE_ALL_WIDTH | 
		 VerticalFieldManager.USE_ALL_HEIGHT | 
		 VerticalFieldManager.NO_VERTICAL_SCROLL);
			
	    LabelField title = new LabelField("title and background");
	    LabelField score = new LabelField("score");
	    add(title);
	    add(score);
			
	    HorizontalFieldManager hfm = new HorizontalFieldManager(
		HorizontalFieldManager.USE_ALL_WIDTH | 
		HorizontalFieldManager.USE_ALL_HEIGHT | 
		HorizontalFieldManager.VERTICAL_SCROLL | HorizontalFieldManager.VERTICAL_SCROLLBAR);
		
	    BitmapField image_1 = new BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );
	    BitmapField image_2 = new BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );
	    BitmapField image_3 = new BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );
	    BitmapField image_4 = new BitmapField(Bitmap.getBitmapResource("bases_60.png"), BitmapField.VCENTER | BitmapField.HCENTER );
		
	    VerticalFieldManager vfm_left = new VerticalFieldManager();
	    //LabelField left_1 = new LabelField("left 1");
	    //LabelField left_2 = new LabelField("left 2");
	    //vfm_left.add(left_1);
	    //vfm_left.add(left_2);
	    vfm_left.add(image_1);
	    vfm_left.add(image_2);
			
	    VerticalFieldManager vfm_right = new VerticalFieldManager(
	           HORIZONTAL_SCROLL | HORIZONTAL_SCROLLBAR);
	    vfm_right.add(image_3);
	    vfm_right.add(image_4);
			
	    hfm.add(vfm_left);
	    hfm.add(vfm_right);	
			
	    add(hfm);
	}
I attached a screenshot of the above code.

Now, I am really confused as to how these fieldmanagers work!

Mark
Attached Images
File Type: png Screenshot-4.png (7.5 KB, 10 views)
Offline  
Old 02-16-2010, 08:14 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

I'm stumped.

If I were you, I would start from scratch and add one thing at a time until I understand what is going on.

One more comment: after spending maany hours on issues like this, I started writing my own custom managers.
Offline  




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