Reputation: 73753
From what I understand the <include>
tag is basically a copy and paste so I created a view with a couple textviews
in it and I replicate that a few times
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000">
<include android:id="@+id/frame_one" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_two" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_three" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_four" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_five" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_six" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_seven" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_eight" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_nine" layout="@layout/frame_layout_normal"/>
<include android:id="@+id/frame_ten" layout="@layout/frame_layout_last"/>
</LinearLayout>
now my question is how can I change the textview
text individually for each of the include tags I created?
obviously I have to get the layout's view id but not sure what to do after that?
this is all that is in the frame_layout_normal
<TextView android:layout_height="50dp"
android:id="@+id/frame_name"
android:layout_width="121dip"
android:layout_alignParentTop="true"
android:gravity="center"
android:textColor="#000000"
android:layout_marginTop="2dip"
android:background="#ffffff"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/frame_number"
android:layout_height="50dp"
android:layout_width="121dip"
android:layout_below="@+id/frame_name"
android:gravity="center"
android:textColor="#000000"
android:layout_marginTop="2dip"
android:background="#ffffff"
android:textAppearance="?android:attr/textAppearanceLarge"/>
Upvotes: 0
Views: 1717
Reputation: 6086
This should work if you wrap the contents of frame_layout_normal in a LinearLayout:
LinearLayout frameOne = (LinearLayout) findViewById(R.id.frame_one);
TextView frameOneName = (TextView) frameOne.findViewById(R.id.frame_name);
<include>
lets you set the id for the top level element, which you are already doing, so just use those ids to get your frames.
Upvotes: 1