I read this
”
It used to be that Android would use a single pass to process
RelativeLayout-defined rules. That meant you could not reference a widget
(e.g., via android:layout_above) until it had been declared in the XML. This
made defining some layouts a bit complicated. Starting in Android 1.6,
Android uses two passes to process the rules, so you can now safely have
forward references to as-yet-undefined widgets.
“
I do not know what is the problem maybe is eclipse problem, but even I use 2.3 I still have problems when I reference some view that is not declared jet so for me it seems like android doesn’t uses two passes to process the rules for relative layout.
note: I always use @+id/widget_name when I declare the widget and @id/widget_name when I reference that widget from other widget. I have noticed that I can use @+id/widget_name even when I just want to reference that widget. I guess that is wrong but why sometimes is works without any complaints ? In my opinion one widget should be allowed to be declared only ones…
My questions is is really android uses two passes ? and I need some guidelines (best practices) for working with relative layouts
I am little confused about how this relative layout parings are made, so any explanations are welcomed
Thanks
@+id/namecreates a new id, if it doesn’t already exist.@id/namereferences an existing id, and will never create one.I’m not sure if you can use
@id/namebefore@+id/namein the same file. If not, I can think of two workarounds:Always use
@+id/name.Define all id’s in the
ids.xmlfile, and always use@id/name.