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
Regular Contributor
Posts: 57
Registered: ‎07-27-2010
My Device: Bold 9700, 9000 and Storm 9520, 9500
My Carrier: SingTel

Display.getHeight on touch device

Hi guys,

 

I am using a 9530 to do development. there is a peculiar behaviour for my application. I will try to summarize

 

1. display main screen A

2. select option to display another screen B

3. pop screen B and push screen A, after input of data

4. Display.getHeight() when re-initializing the content of screen A returns the height of screen B instead of screen A.

 

This is a problem as screen B has a keyboard, for user input, so Display.getHeight returns half of the actual screen size. I tried Display.getVerticalResolution() and it returns me a constant value. But it is in pixels.

 

Do i add on the keyboard height? Or is there anyway for me to get the full height by some other function?

Developer
Posts: 31
Registered: ‎03-01-2010
My Device: 9300
My Carrier: O2

Re: Display.getHeight on touch device

That sounds like it still thinks screen B is being displayed.

 

Could you cache the height of the screen in your class for screen A and use the cached value rather than asking the OS for the height?

Regular Contributor
Posts: 57
Registered: ‎07-27-2010
My Device: Bold 9700, 9000 and Storm 9520, 9500
My Carrier: SingTel

Re: Display.getHeight on touch device

i can do that but it would not be a very good method to implement. especially if i were to tilt the device etc. Currently i'm getting the model for the device and then using hardcoded values as a workaround. Anyone got any ideas?

Developer
Posts: 31
Registered: ‎03-01-2010
My Device: 9300
My Carrier: O2

Re: Display.getHeight on touch device

I agree, its not a very good method for the reasons you state.  You would have to re-query the dimensions when the device rotates to get the new screen dimensions.

 

It sounds like your code still thinks the wrong screen is being displayed.  Do you have any sample code?

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

Re: Display.getHeight on touch device

Alternatively perhaps the keyboard is still being displayed?

 

Perhaps Screen A should deliberately hide the keyboard before doing the the getHeight()?

Regular Contributor
Posts: 57
Registered: ‎07-27-2010
My Device: Bold 9700, 9000 and Storm 9520, 9500
My Carrier: SingTel

Re: Display.getHeight on touch device

This method lies in my Util class to retrieve the Display height

 

 public static int getScreenHeight()
    {

       int ht = Display.getHeight();

        return ht;
    }

 

The code below lies in my screen B. The variable prevScreen referes to screen A.

 

        UiApplication.getUiApplication().popScreen(this);
        this.invalidateLayout();
        if (null != prevScreen)
        {
                UiApplication.getUiApplication().pushScreen(prevScreen);
        }

After this is done, when i do a Util.getScreenHeight() , it returns me the height of screen B, taking the height of the keyboard into account.

 

Thank you...