Suppose I have two identical layouts other than the values of a TextView field. Presently, I either have modify the layout at runtime or duplicate the XML.
I don't have a concrete proposal about how to implement this, but something akin to passing function parameters to the included files would be great, though I don't think xml supports this sort of thing. My guess is it would require some xslt.
For example to pass two parameters "hello" and "world" to layout1: <include layout="@layout/layout1" params="textView=hello|editText=world" />
Description
I don't have a concrete proposal about how to implement this, but something akin to passing function parameters to the included files would be great, though I don't think xml supports this sort of thing. My guess is it would require some xslt.
For example to pass two parameters "hello" and "world" to layout1:
<include layout="@layout/layout1" params="textView=hello|editText=world" />
layout1:
<merge><TextView text="@param/textView"><EditText hint="@param/editText"></merge>
An alternate implementation would break encapsulation and would allow the include statement to override values like:
<include layout="@layout/layout1" overrides="@id/textView.text=hello|@id/editText.hint=world" />
<merge><TextView id="@+id/textView"><EditText hint="@+id/editText"></merge>