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
New Contributor
jbzs
Posts: 6
Registered: ‎06-30-2010
My Device: None
Accepted Solution

Multiple items in a VerticalFieldManager

Hello,

 

     I'm trying to create a simple screen that has to images in it. To do this, I am creating a VerticalFieldManager (although to my understanding the screen itself acts as one) then adding bitmapfields to it on opposite corners. However, I find that only the first bitmap that I add to the screen is displayed. What's going on here? I know the images load properly because I have altered the order in which they appear, and it is always the case that only the first one added loads.  Any help is appreciated. Here is my code:

 

public class MyScreen extends FullScreen {

    public MyScreen() {
        VerticalFieldManager _mainManager = new VerticalFieldManager();
        _mainManager.setBackground(BackgroundFactory.createSolidBackground(0));
        add(_mainManager);
        BitmapField _bitmap;
        Bitmap _mainmenutop;
        Bitmap _cursor;
        BitmapField _bitmap2;

        _bitmap = null;
        _bitmap2 = null;

        _mainmenutop = Bitmap.getBitmapResource("mainmenutop.png");
        _bitmap = new BitmapField(_mainmenutop, BitmapField.TOP
                | BitmapField.RIGHT);
        _cursor = Bitmap.getBitmapResource("cursor.png");
        _bitmap2 = new BitmapField(_cursor, BitmapField.BOTTOM
                | BitmapField.LEFT);

        _mainManager.add(_bitmap);
        _mainManager.add(new SeparatorField());
        _mainManager.add(_bitmap2);


    }

}

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Multiple items in a VerticalFieldManager

I just wonder if in fact the images are there, but because they are not focusable, the screen will not let you scroll to them.  Add a NullField between the images and after the last one (or In fact any focusable Field not just a NullField) and see if that allows you to scroll and see you images.

New Contributor
jbzs
Posts: 6
Registered: ‎06-30-2010
My Device: None

Re: Multiple items in a VerticalFieldManager

Hi,

     I tried your suggestion:

 

        _mainManager.add(_bitmap);
        _mainManager.add(new NullField());
        _mainManager.add(_bitmap2);
        _mainManager.add(new NullField());

 

But no luck. I also tried it with SeparatorFields and NullFields and no luck either.

 

-Juan

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Multiple items in a VerticalFieldManager

Can you try adding super(NO_VERTICAL_SCROLL) as the first line in your screen's constructor (right after public MyScreen() ) and tell us what you see?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Multiple items in a VerticalFieldManager

Incredibly, the main problem is Field.TOP in your _bitmap!

 

I knew VerticalFieldManager did not work well with Field.TOP and Field.BOTTOM, but that was really unexpected.  I wonder how many experts could predict that...

 

So remove Field.TOP from the style bits in your _bitmap and make sure you don't use VerticalFieldManager or Screen with VERTICAL_SCROLL (or Field.BOTTOM will send your field down to virtual infinity).

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
TobiasReaper
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

Re: Multiple items in a VerticalFieldManager

and if you were to make Peter's suggestion work for you, you'd want to try something like this

 

_mainManager.add(_bitmap);

_mainManager.add(new NullField(Field.Focusable));
_mainManager.add(_bitmap2);
_mainManager.add(new NullField(Field.Focusable));

New Contributor
jbzs
Posts: 6
Registered: ‎06-30-2010
My Device: None

Re: Multiple items in a VerticalFieldManager

Problem solved (removing TOP fixed it.) Thanks for all the help.