Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:13:56+00:00 2026-06-03T01:13:56+00:00

I need to dynamically add a ‘template’ layout to my activity at runtime based

  • 0

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?

<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>

Thanks, any guidance is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:13:59+00:00Added an answer on June 3, 2026 at 1:13 am
        LinearLayout Parent = (LinearLayout) findViewById(R.id.linearLayout);
    
        View child = getLayoutInflater().inflate(R.layout.main_new,null);
        Parent.addView(child);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Android Activity, I need to add a single View dynamically (at runtime),
I have a GridView that I need to dynamically add TemplateField elements to. My
I have a table of data that I need to dynamically add a column
I have a dataGrid(not dataGridView) in which i need to add Checkbox dynamically at
I need to add css height to each page dynamically with jQuery. So far
I need to be able to add rows to a table dynamically with jQuery
I need to create several Divs dynamically, and I need to add onmouseover event
I have a DataGrid and I need to add an Expander control dynamically to
I need to dynamically create textbox. This is my code, but with this I
I need to dynamically add a div around items then run a second bit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.