Wednesday, February 2, 2011

[android-developers] Re: How to tell in code the orientation

Well, he did say he was making decisions about layouts, and layouts
are customarily set in onCreate, and onCreate is clearly called with
orientation changes unless you'd rather it not.

That said, I have authored at least two activities that have the same
general layout for landscape and portrait, and I don't have those
activities automatically respond to orientation changes, but I *do*
dynamically create a set of views on demand differently depending on
current orientation, which is not something I need to do in onCreate.
So I need to check the orientation at the time those views are
created.

Doug

On Feb 2, 7:08 pm, Indicator Veritatis <mej1...@yahoo.com> wrote:
> Shouldn't he be listening for the change configuration broadcast event
> rather than just checking a flag? Or perhaps he should declare that he
> handles it himself, and handle it in onConfigurationChanged(config).
> In that case, he can read the new configuration from config.
>
> But when I see people simply asking how to check the current
> configuration (in this case screen orientation), it -sounds- like they
> have misunderstood how Android approaches this issue. Then they will
> be blind-sided when they find onCreate() being called when the user
> tilts his phone.
>
> On Feb 2, 3:50 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
> > If you load a layout resource via setContentView() or a
> > LayoutInflator, Android will choose the right resource automatically
> > based on orientation.
>
> > If you are generating your UI directly in Java code, either switch to
> > using layout resources, or use the orientation field on the
> > Configuration object to find out what the current orientation is.
>
> > On Wed, Feb 2, 2011 at 6:45 PM, kiros88 <ghui...@gmail.com> wrote:
> > > Hi so im going to make a layout for both horizontal and vertical
> > > layout but im trying to figure out right now is how u make the system
> > > know when i guess u create it? is there a way to check programmically?
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscribe@googlegroups.com
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training in London:http://bit.ly/smand1andhttp://bit.ly/smand2
>
>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment