Search code examples
layoutblackberryblackberry-stormcurvefieldmanager

Blackberry fieldManager issue 8900 vs. 9550


My buttonset is kind of moving to the right after pushing and closing a new screen.

I added some Buttons to a VerticalFieldManager. Then I added the verticalFieldManager on a horizontalFieldManager to center the buttons.

The problem is on a BB 8900(Curve) is everything fine. On a 9550 (touch screen) it works only when Iam opening the screen the first time. But if I open based on this screen another screen and close the opened screen the buttons are moving to the right. But only on the 9550 ??? On the Curve I can open a new screen and close the new one and it looks like it should. Does someone know this problem?

VerticalFieldManager verticalFieldMng = new VerticalFieldManager();      
            ButtonField btnSendAdrViaSMS = new ButtonField("test");
            verticalFieldMng2.add(btnSendAdrViaSMS);
            ButtonField btn2 = new ButtonField("test2");
            verticalFieldMng2.add(btn2);
            ButtonField btn3 = new ButtonField("test2");
            verticalFieldMng2.add(btn3);

            HorizontalFieldManager horizontalFieldManager = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
            horizontalFieldManager.add(verticalFieldMng2);
            add(horizontalFieldManager);

For opening the new screen i use

    Screen_SendSMS sendSMS = new Screen_SendSMS("",link);
UiApplication.getUiApplication().pushModalScreen(sendSMS);

And to close the screen i use the regular "back key" of the BB device without overwritting it.


Solution

  • Thats pretty odd, but doesn't surprise me in BB.

    UPDATE: After reviewing some of my code to center things, I can say that HorizontalFieldManager, because of the scrolling I guess, has problems to center fields. So when I need to center horizontally I use a VerticalFieldManager, and when I have to center vertically I use an HorizontalFieldManager.

    The basic pattern to center fields is this:

        VerticalFieldManager vfm = new VerticalFieldManager(Manager.USE_ALL_WIDTH);
        Field toCenter = new <Field>(DrawStyle.HCENTER | Field.FIELD_HCENTER );
        vfm.add(toCenter);
    

    In vertical, it would be:

        HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.USE_ALL_HEIGHT);
        Field toCenter = new <Field>(DrawStyle.VCENTER | Field.FIELD_VCENTER );
        hfm.add(toCenter);
    

    You can combine the flags with other style flag with arithmetic OR operator.

    In your case you'd have to do this twice: firts with the buttons and the vfm, then with the vfm and hfm.