Premier
Premier

Reputation: 4228

Android layout <include /> tag

i want to use include tag in my xml layout to recycle a common layout part.

Android documentation says i can modify some attribute of imported layout, for example

<include layout="@layout/topbar" />

Include topbar layout without specify width and height.

<include layout="@layout/topbar" android:layout_width="fill_parent" />

Include topbar layout with specific width.

So, in my topbar layout, i've a textview without text, can i set textview text from include tag like below?

<include layout="@layout/topbar" android:text="Hello world" />

Thank you.

Upvotes: 2

Views: 1444

Answers (1)

emmby
emmby

Reputation: 100464

No, you'll need to do this in code. In your activity, call findViewById() to find the TextView, then call TextView.setText() to set the text.

Upvotes: 4

Related Questions