I've been attempting to use the <include> tag in some layouts and it
seems that these are of limited use because of the flat namespace of
the R.id.x approach.

Suppose I have a layout (attribs and xml namespace decl omitted for
clarity).

component.xml

<LinearLayout   android:id="@+id/row" >
  <ImageView    android:id="@+id/image"  />
  <TextView      android:id="@+id/text"     />
</LinearLayout>

Now include this twice inside a 'parent' view

flipper.xml

<ViewFlipper android:id="@+id/flipper" >
  <include android:id="@+id/row1"  android:layout="component" />
  <include android:id="@+id/row2"  android:layout="component" />
</ViewFlipper>

Now in my java code I have a conundrum. I am not able to identify each
individual instance o f the children included layouts root view. In
the include tags I can replace the root id with "row1" and "row2"  so
I can find the individual linear layouts using findViewById

eg:

LinearLayout row1 = (LinearLayout) findViewById(R.id.row1)
LinearLayout row2 = (LinearLayout) findViewById(R.id.row2)

However, I can't easily access the two instances of the TextView which
are children of row1 and row2 because all I have to play with is the
single id "text"

ie:

TextView  text = (TextView) findViewById(R.id.text);

In this case, which instance (row1.text or row2.text) does this refer
to,  both of them, or none?

I guess I would need to use another means of accessing the children of
row1 and row2.

Anyone know how this can be done?








-- 
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