I am generating a display from an input script. The top and bottom sections are repeatable – as in a merge or include file – except for one minor text change which can be handled easily by a ‘setText()’ instruction. The middle section is dictated by the script and can be of variable length and content. The generated view is then added as a child view to a ScrollView.
Currently, I have a script string which describes both the top and bottom sections and a ‘marker’ in the middle which is replaced by the variable ‘middle section’ script provided by a user database. This structure I believe could be more efficiently expressed and generated if I could incorporate a ‘merge’ or ‘include’ facility in the script. This implies that I would have to be able to implement the merge or include function in Java code.
Any suggestions?
This is part of a code I used to generate a
LinearLayoutfull of a repeatingLinearLayoutin a recent project. It functions the same way as<include />, by inflating a layout XML file.You should be able to adapt this to your need. The key here is calling the
.inflate()method, which creates a new instance of that layout.