On Sun, Mar 6, 2011 at 2:51 PM, Hari Edo <hari....@gmail.com> wrote:

> I once tried to have small rotation-independent clusters of
> views included from layout/, while the activity xml was in
> layout-land.  It seemed to have trouble finding layout/ to
> resolve include tags.  Trouble of the NullPointerException
> variety.
>

There should be no such problem.

This is really very simple: there is one resource "thing" for all of the
configurations.  Any time you try to load that resource (such as with
setContentView() or <include />), the framework will retrieve whichever of
the resources under that name best matches the current configuration.

The <include /> tag works *exactly* the same as setContentView(), which
works exactly the same as every other resource lookup.

If you want to have a layout that you use in different configurations, just
do as Romain suggested and put it in the base layout/ dir.  Do NOT put any
different layouts in any other configurations, or else one of those
different ones will be picked if the current configuration matches them.

Also if you have a layout in some other configuration (layout-land/ or
whatever), you should ALWAYS also have a layout in the base configuration.
 Otherwise if you get in a situation where the current configuration doesn't
match (for example here you are now running portrait) then trying to load
the layout will fail because there is no value defined that matches the
current configuration.

(Of course everything I say here about layouts also applies to all other
resources; configurations are a generic resource concept, nothing specific
to layout resources.)

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to