Are you allowed to reference an ID to a View that is defined later in
the XML?  Sometimes when I do this it works, and other times I get a
compilation error.  I am not sure if this is the Android compiler/
parser, or my IDE (IDEA) failing.

For example, if you have a RelativeLayout for Component A, which
defines:

   ...
   android:layout_above="@id/component_b"

do you need to define "component_b" above the reference to it in the
XML (even though logically, component_b is "below" component_a when
viewed on the screen)?  Assume component_b is not in the
RelativeLayout itself.

As I mentioned, I had written an XML layout where "component_b" was
indeed defined after "component_a", and everything compiled, but when
I re-compiled the app (via the IDE) the compilation failed with this
error:

my_layout.xml:18: error: Error: No resource found that matches the
given name (at 'layout_above' with value '@id/component_b').

I am positive the layout compiled the first time (or maybe the first
few times), but then it "stopped" working, and I was forced to move
component_b above it's reference in the XML.

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

Reply via email to