As a N00B I'm still finding my way round the Android (1.5) API &
Eclipse SDK and plugin.  I have come across the following oddity...


My aim is to create a main view (a View Animator) which will switch
between child views.  The question is _not_ about this - and I
appreciate the example may not be the right or best way to achieve
what I want.  However...


I create a new Android project.  By default this creates a layout/
main.xml resource file.  I will modify this to become my ViewAnimator
view.

First though, under layout I create two LinearLayout files
(layout1.xml and layout2.xml).  To both I add an android:id="@+id/
layoutN" where N is one and two respectively.

In main.xml - I change it to have a ViewAdaptor with two child
references, referencing "@id/layoutN".

I save all, clean and compile with no errors.

But - and here comes the crunch - if I refactor and rename layout2.xml
to zlayout2.xml, the main.xml file has the error:

No resource found that matches the given name (at 'id' with value '@id/
layout2'). main.xml ResourceTest/res/layout line 10

(This occurs when zlayout2.xml is renamed to anything appearing after
"main")

Why does main.xml reference to resource in layout2 depend on the
filename?  Is there something I have missed regarding referring to
other resources across different files?

The actual file contents are:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<ViewAnimator
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:id="@+id/animator1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <LinearLayout android:id="@id/layout1" />
  <LinearLayout android:id="@id/layout2" />
</ViewAnimator>


layout1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/layout1">
</LinearLayout>

(z)layout2.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/layout2">
</LinearLayout>


Finally, if I comment out the error line in main.xml, then compile and
look at R.java under the gen folder I can see the layout2 id.


Pointers to further information gladly appreciated; I have browsed the
web but was unable to find any further help on this.


Many thanks,

Nigel Eke
--
http://nigel-eke.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to