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 7922041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:49:00+00:00 2026-06-03T16:49:00+00:00

I have a generic layout in XML I would like to programmatically add after

  • 0

I have a generic layout in XML I would like to programmatically add after filling it with content (i.e. change the text on a text view, set a listener for a button, etc.) multiple times to a on-screen layout. I know I can add Views using layout.addView(View V), but

how do I construct a new layout from an XML file?

  • 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-03T16:49:02+00:00Added an answer on June 3, 2026 at 4:49 pm

    You can do that with the LayoutInflater service. Get a reference to it by loading it like this:

    LayoutInflater inflater =
        (LayoutInflater)this.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
    

    Then you can create a layout from an XML resource like this:

    View view = inflater.inflate( R.layout.layoutname, null );
    

    The layoutname here is simply the name of the XML file in your res/layout directory.

    Finally you can add this view to your layout using the addView function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that would like to have a generic function for
I have two XML layouts declared in the res/layout folder one contains the generic
I have generic type that looks like: public class GenericClass<T, U> where T :
I have this simple layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical >
I have an Index.cshtml view: @model AttendenceModel @{ Layout = ~/Views/Shared/_Layout.cshtml; } @using (Html.BeginForm(VisOppsummering,
For example, I have this class: using System; using System.Collections.Generic; using System.Linq; using System.Text;
I have created a Generic WPF Control, so the layout is all defined in
i have a activity which extends ListActivity. The Layout contains some generic widget an
I have generic list which must be a preserved order so I can retrieve
I want to write in Delphi (2009 - so I have generic dictionary class)

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.