It's easy: LinearLayout row1 = (LinearLayout) findViewById(R.id.row1) TextView text1 = row1.findViewById(R.id.text); LinearLayout row2 = (LinearLayout) findViewById(R.id.row2) TextView text2 = row2.findViewById(R.id.text);
On Tue, Jan 12, 2010 at 11:09 AM, free1000 <prwfree...@googlemail.com> wrote: > 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 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 > -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. 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