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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:42:23+00:00 2026-05-25T12:42:23+00:00

I am attempting to create a program with a set of dynamically loaded layout

  • 0

I am attempting to create a program with a set of dynamically loaded layout “pages”. I have the base layout created with a minimal default skeleton of the Views common to each page. For each page I was going to hard code all the views to be swapped (:facepalm). My next thought was to create a text file and put the necessary data in a well formatted design. Only then I realized that’s exactly what the XML files are. So what I would like to do is create an XML file of the pages with the data exactly as it would appear in the original layout file. Then as each page is loaded (possibly unload another page), pull the XML data for that page and insert it into the current base layout structure.

My page data

<?xml version="1.0" encoding="utf-8"?>
<pageList>
    <page:1>
        <Button .../>
        <EditText .../>
    </page>
    <page:2>
    ...
</pagelist>

The base XML layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:weightSum="1">
<LinearLayout android:id="@+id/linearLayout1"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:layout_weight="1.00" android:weightSum="1">
    <EditText android:id="@+id/editText1" android:inputType="textMultiLine"
        android:layout_width="0dp" android:layout_weight="0.30"
        android:layout_height="match_parent"></EditText>
    <RelativeLayout android:layout_width="0dp"
        android:id="@+id/orientationLayout" android:layout_weight="0.70"
        android:layout_height="match_parent">
        <dynamically insert my PAGE here>

I am new to Android programming and have only a little experience in generating interfaces from XML. In programming C# and XML for a previous job, I would have to pull the data directly from an embedded XML file and use that to create the Button or TextBox myself. Do I need to do similar in this case or is there a way to automatically load it?

I have looked this up for a while and most answers I found on this site and other places are from months ago or longer. Those answers tend to range from IMPOSSIBLE to do it yourself. I’m hoping maybe in the past few months there might have been a change to the system I have yet to find.

  • 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-05-25T12:42:24+00:00Added an answer on May 25, 2026 at 12:42 pm

    You are probably looking for a ViewStub.

    A ViewStub is an invisible, zero-sized View that can be used to lazily
    inflate layout resources at runtime. When a ViewStub is made visible,
    or when inflate() is invoked, the layout resource is inflated. The
    ViewStub then replaces itself in its parent with the inflated View or
    Views. […]

    You can use this like a normal view in your layout and use findViewById() to reference it in code. After that use ViewStub.setLayoutResource() to set layout that you want to show and call ViewStub.inflate() to show it. This way you can write a normal XML
    layout file for every (sub-)page you need.

    Also see this article.


    Edit: Or probably not, I have to mention that the stub gets removed from the view hierachy after inflating. So, depends on your actual use case if this is helpful.

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

Sidebar

Related Questions

I have Eclipse Helios with a java program set up. I'm attempting to create
I'm attempting to create my first WCF service. I've created the service and now
I am attempting to create a basic Hangman program. It's an array of tags
Hi so i am using msVS++2010 and have been attempting to set up SFML
I am attempting to create a fixed step loop in my program, but for
I am attempting to create a quiz for my C# program using an Access
Am attempting to teach myself to program using Tcl. The task i've set myself
I'm attempting to create a java program that will allow me access to an
I've been attempting to create a pen tool for my Java drawing program using
I'm attempting to create a client/server program, but I'm finding some difficulty continuing with

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.