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
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Screen Orientation event

Is there an event or callback that is associated with when the screen changes orientation?

I know that sublayout() is called, but what I need to do has to be done outside this method. That is why I am wondering if there is another event.

 

Thanks

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Screen Orientation event

You can get the device orientation from the Accellerometer interface.

 

Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: Screen Orientation event

Thanks for the reply.

But what I was hopping to find is just an event when the orientation changes.

 

Thanks

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Screen Orientation event

[ Edited ]

The only other suggestion is to override one of the layout methods, like subLayout(), which is called when the screen orientation changes. 

 

So what is the reason that you cannot use this method?

 

 

Message Edited by RexDoug on 02-02-2009 01:19 PM
Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: Screen Orientation event

Well I did try to use it ( but did not spend a lot of time on it) as follows:

 

in the sublayout()

1- Rebuild part of the screen that contains some bitmaps

2- call super.sublayout();

 

This caused an inifinite loop to sublayout();

 

Thanks

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Screen Orientation event

Don't call super.subLayout()  Smiley Happy

 

 

 

 

Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: Screen Orientation event

Sorry I missed in my previous message that if I do not call super.subLayout(), the screen becomes black. Nothing is shown.

 

Thanks

Rab

BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Screen Orientation event

What changes are you making in the sublayout method?  They may be triggering the additional sublayout call.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 83
Registered: ‎02-03-2009
My Device: 9500/9520/9800/9810
My Carrier: TMobile

Re: Screen Orientation event

I know, that this might be cheating - but with this I manages to detect that the orientation of my net.rim.device.api.ui.container.MainScreen have changed

 

 

private int lastPaintWidth = Display.getWidth(); private int lastPaintHight = Display.getHeight(); protected void paint(Graphics g){ super.paint(g); // just to detect, if display orientation have been changed... int w = Display.getWidth(); int h = Display.getHeight(); if(w!=lastPaintWidth){ lastPaintWidth=w; myMethodThatHandlesLayoutChanges(); } else if(h!=lastPaintHight){ lastPaintHight=h; myMethodThatHandlesLayoutChanges(); } }

the advantage of this code is, that it also will exectue your 'myMethodThatHandlesLayoutChanges()' when the user display the Keyboard (on a Storm devive)...

 

Matthias

 

[FileScout] | [iMazing] | [GPSLogger II] | [Iconify] | [TOMPlayer]
Developer
Developer
Posts: 283
Registered: ‎07-22-2008
My Device: Not Specified

Re: Screen Orientation event

emac, thank you for the suggestion. I will see if It can be adopted.

 

As an answer to Mark, I have a header section that contains a set of blips ( Bitmaps) whose width is calculated based on the total screen width. The area needs to be layed out every time the screen changes orientation, because the bitmap widths will change to fit across the screen.

 

Thanks