android - Creating XML Layout file composed from other XML files? -
i know can seem weird question me handy if compose layout xml set of other xml files pointed main xml file. reason have list item views defined in xml , reuse in other places. possible or way coping , pasting it?
you can include different layout files in single layout using 'include' tag
<linearlayout> <include layout="@layout/toinclude1" /> <include layout="@layout/toinclude1" /> </linearlayout>
another way viewstub. if want load asynchronously layout can have:
<viewstub android:id="@+id/stub" android:inflatedid="@+id/subtree" android:layout="@layout/mysubtree" android:layout_width="120dip" android:layout_height="40dip" />
and in code when want can write:
viewstub stub = (viewstub) findviewbyid(r.id.stub); view inflated = stub.inflate();
for reference: http://developer.android.com/reference/android/view/viewstub.html
Comments
Post a Comment