Reputation: 5975
I'm in the process of writing a toolbar in one of my views via XML - a toolbar that will be cloned in multiple views. Is there anyway I can reference the same XML in all my views, as opposed to copying and pasting the code? Am I forced to use a Fragment or can I programmatically add the same XML?
Upvotes: 3
Views: 399
Reputation: 6244
You should use the include tag:
http://developer.android.com/resources/articles/layout-tricks-reuse.html
<include layout="@layout/toolbar" />
Edit:
Looks like the link above is now dead, here's a working one: http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
Upvotes: 8