Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting attribute of child element of included layout
    text
    copied!<p>I have a main.xml file describing the layout of my main activity:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;include layout="@layout/mylayout" /&gt; &lt;include layout="@layout/mylayout" /&gt; &lt;include layout="@layout/mylayout" /&gt; &lt;include layout="@layout/mylayout" /&gt; &lt;include layout="@layout/mylayout" /&gt; &lt;include layout="@layout/mylayout" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and its included layout xml file (mylayout.xml):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mylayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello world" /&gt; &lt;Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I just want to include "mylayout" in my main layout 5 times, but instead of seeing "hello world" 5 times, I want the TextView to contain custom text.</p> <p>Is there any way to do this by setting some attribute on the include element to override the child TextView's text? What would be the best approach to take to accomplish this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload