Insert Layouts dynamically into an activity at runtime

aleece377

New Member
I need to dynamically add a 'template' layout to my activity at runtime based on the click of a button.Shown in the code block below is a simplified version of my layout. The contents of HEADER C (i.e. BODY C1, BODY C2 ... BODY Cn) are the components that need to be added at runtime. They are all of the same format and are defined in a separate xml file with a relative layout. How do I accomplish this task? I have tried a LayoutInflater, but was unsuccessful. Does LayoutInflater require a LinearLayout to inflate? \[code\]<SCROLLVIEW> <RELATIVE_LAYOUT> ____________ HEADER A ____________ BODY A </RELATIVE_LAYOUT> <RELATIVE_LAYOUT> ____________ HEADER B ____________ BODY B</RELATIVE_LAYOUT><RELATIVE_LAYOUT>____________HEADER C ____________ BODY C1 ____________ BODY C2 . . . ____________ BODY Cn<RELATIVE_LAYOUT></SCROLLVIEW>\[/code\]Thanks, any guidance is appreciated!
 
Back
Top