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
New Contributor
ashokreddy4444
Posts: 2
Registered: ‎10-17-2011
My Device: blackberry developer
My Carrier: blackberry developer

how can we handle orientation changes and when sublayout() will get call?

Hi,

i am new to blackberry..

in my app i am displaying one image in potrait mode..once when i change more i have to update x and y position..

where i can update there changes...?

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: how can we handle orientation changes and when sublayout() will get call?

sublayout gets called when a manager is first displayed, when the phone orientation changes, when fields are deleted, added or replaced and when a field requests to re-layout (for example, when you type in EditField, it will eventually go out of its current boundaries and try to word-wrap; at this moment, it will invoke updateLayout).

 

What you seem to want (place an image depending on the screen orientation) is not the easiest task. It is best done with either a custom manager or, say, an AbsoluteFieldManager with its setPosChild method (don't confuse with setPositionChild - the latter can be called only inside sublayout and is the tool to use in a custom layout manager). Make sure that you don't invoke setPosChild if the position is already correct (can find out by calling the field's getExtent and checking its x and y) - otherwise you'll create an infinite loop of sublayout invocation.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.