1

I have a layout xml file which includes another smaller xml file.

<include layout="@layout/text" android:id="@+id/test1"/>
<include layout="@layout/text" android:id="@+id/test2"/>

where my text.xml is

<merge xmlns:android="http://schemas.android.com/apk/res/android">
        <TextView android:id="@android:id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
        />
</merge>

My question is how can I specify different text view in my text view in test1 and test2 in my layout xml file? Or I have to do that in my java code?

Thank you.

n179911
  • 19,547
  • 46
  • 120
  • 162
  • I am trying to approach an application in the same way. Did you ever find out if this is possible? I would expect that android would have a way to pass a resource through the include to the merged view. – Casey Watson Jun 14 '10 at 04:10
  • I'm fairly certain that you have to do that in java code. My experience of xml is that it is 100% static. – keyser Apr 21 '11 at 10:07

1 Answers1

0

Similar to this answer on SO: https://stackoverflow.com/a/10821976/2543138. Yes, it can be done in xml, you just have get the id of the include first in the code and then get the text element.

Community
  • 1
  • 1
brwngrldev
  • 3,664
  • 3
  • 24
  • 45