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
Developer
Posts: 248
Registered: ‎11-23-2009
My Device: Not Specified
Accepted Solution

What should getHeight return?

Hi

 

i am working on the torch simulator. the getwidth method return 360 which i know is correct but the getwidth returns 1073741823. Isnt it supposed to return 480??

can anyone tell me why does this happen and how can i resolve it?

Thanks

Developer
Posts: 105
Registered: ‎06-23-2010
My Device: 9000
My Carrier: vodaphone

Re: What should getHeight return?

In my experience this generally happens on controls that have not been laid out yet. If you want the height of the screen, not the control, then call Display.getHeight()

 

 

-matt

Press Kudos if this helped - ;-)
Regular Contributor
Posts: 71
Registered: ‎03-18-2009
My Device: Not Specified

Re: What should getHeight return?

yup thats the value of the height of the field BEFORE layout. call childlayout(field, getPreferredWidth(), getPreferredHeight())  then check the height again - it should be something more sensible.

 

Note you have to override getPreferredWith() and getPreferredHeight() as well

 

Developer
Posts: 466
Registered: ‎03-04-2009
My Device: 8520
My Carrier: some

Re: What should getHeight return?

well, if you manager has USE_ALL_HEIGHT style, then it might return that value.
Got resolved! Press kudo icon!
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: What should getHeight return?

 


Sakberry wrote:

Hi

 

i am working on the torch simulator. the getwidth method return 360 which i know is correct but the getwidth returns 1073741823. Isnt it supposed to return 480??

can anyone tell me why does this happen and how can i resolve it?

Thanks


 

You are asking the wrong question. The question you should be asking is "Where can I fit the field which is 0x3FFFFFFF=Integer.MAX_VALUE >> 1 high?" Of course, not anywhere on the screen. So what entity might think it's got that much height available for displaying something? And the answer is "A vertically scrolling manager". Where did you get that manager from? Read this knowledge base article to find out:

MainScreen explained

So there is either nothing to "resolve" (because it's not a problem - it is a perfectly valid behaviour) or a simple NO_VERTICAL_SCROLL flag to add to your MainScreen.

----------------------------------------------------------
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
Posts: 466
Registered: ‎03-04-2009
My Device: 8520
My Carrier: some

Re: What should getHeight return?

@arkadyz
great explanation, man!
Got resolved! Press kudo icon!
Highlighted
Developer
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550
My Carrier: Vodaphone

Re: What should getHeight return?

I think you can use getHeight(). It will only work if the button is already drawn.