0

I have a Labelfield, EditField and a Button which are centered align vertically. This three fields i have added in a Verticalfield manager which is then added to a Horizontal Field Manager. And finally the HFM is added to another VFM. Now in the 9800 device or 9380 curve i have observed that when i am touching the Edit field, virtual keypad is coming. And it is hiding the Edit Field partially.

I want to move the things up when the virtual keyboard appeared. How can i make it. My code is here:

    HorizontalFieldManager hfm = new HorizontalFieldManager();
    VerticalFieldManager vfmComponent = new VerticalFieldManager(USE_ALL_WIDTH);
    vfmComponent.add(lfServerUrl);
    vfmComponent.add(mEfURL);
    vfmComponent.add(mBtnSave);
    hfm.add(vfmComponent);
    int topEmptySpace = (Display.getHeight() - (Bitmap.getBitmapResource(mStrTopBar).getHeight() + hfm.getPreferredHeight() + 25)) / 2;
    hfm.setMargin(topEmptySpace, 0, 0, 0);
    VerticalFieldManager vfmMain = new VerticalFieldManager(VERTICAL_SCROLL| NO_HORIZONTAL_SCROLL );
    vfmMain.add(hfm);
    add(vfmMain);

Please Help.

CRUSADER
  • 5,486
  • 3
  • 28
  • 64
Arindam Mukherjee
  • 2,255
  • 11
  • 48
  • 83
  • 1
    Can you explain why you have so many nested managers? If this code is placed in a `MainScreen` subclass, the screen already comes with a built-in `VerticalFieldManager`. I don't see why you can't just use that manager, and get rid of `hfm`, `vfmComponent`, and `vfmMain`. But, it could be that I just don't understand your design. Perhaps a screenshot would help? This matters, because you may have triggered this bug by the complicated layout, and a workaround may require knowing which vertical field manager needs to be scrolled. – Nate Aug 23 '13 at 22:20
  • I have fixed it by customizing my top vfm. So no need to add so many managers. Somehow you right here. – Arindam Mukherjee Aug 24 '13 at 11:39

1 Answers1

1

The same question was also asked on the BB forums here; http://supportforums.blackberry.com/t5/Java-Development/Virtual-keyboard-is-hiding-the-part-of-the-edit-Field/td-p/2553879

The answer given involved creating a specialised manager which 'centered' a Field with in it, by overriding the sublayout for that Manager. Then the Fields to be centered where placed inside another standard Manager, which was added to the centering Manager. This meant the centering Manager had to deal with only one thing. the Final 'trick' was to define the MainScreen as non scrolling, which meant the centering Manager was given the height it could work with, and this height changed when the virtual keyboard was added, to the sublayout was called again and the centering Manager could adjust the position.

There is more on that Thread in the BB forums, including references to various KB articles and sample code. So please reference that Thread for more information.

Peter Strange
  • 2,640
  • 11
  • 11
  • I used that.same post from myself. Any way thanks again Peter. – Arindam Mukherjee Aug 24 '13 at 16:16
  • I figured it was the same question - just wanted to tidy it up in both places! Thanks for the thanks, it is no problem, glad to help. And in fact, a 'centering manager' is something I have meant to post for ages, your question gave the opportunity. – Peter Strange Aug 25 '13 at 11:16