Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top