Android inflating views
<p>Difficult to try and phrase this question, but I will try my best.</p>

<p>Basically, I have an application and I would like to split the code up more. To try and explain this, will give an example of one of my screens.</p>

<p>In my home screen, I have a title, user details, balance, next bill details and usage details. I want to split each of these sections into their own views. So what I have in my main XML file is I have 5 different RelativeLayouts, like this</p>

<pre><code>&lt;RelativeLayout android:orientation="vertical"
    android:layout_below="@+id/title" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/layout1"&gt;


&lt;/RelativeLayout&gt;
</code></pre>

<p>One for each function I want to have on my home screen. And as you can see I also have each layout set below the previous layout, so the order is title, layout1, layout2, layout3, layout4. (The reason I am doing this is, that I want each layout to be interchangable, i.e. I could remove layout2, and order then be title, layout1,layout3,layout4 as I may not need the 2nd layout depending on what is required of the app)</p>

<p>So in my main activity class, I have called each of these layouts.</p>

<pre><code>    layoutTitle = (RelativeLayout) findViewById(R.id.title);
    layout1 = (RelativeLayout) findViewById(R.id.layout1);
    layout2 = (RelativeLayout) findViewById(R.id.layout2);
    layout3 = (RelativeLayout) findViewById(R.id.layout3);
    layout4 = (RelativeLayout) findViewById(R.id.layout4);
</code></pre>

<p>Then I use layout inflator like so </p>

<pre><code>View view;
    LayoutInflater inflater = (LayoutInflater) getBaseContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.userdata, null);
</code></pre>

<p>to set up the layout for each layout I have defined in my xml file. </p>

<p>What I want to know is, is it possible to inflate another activity rather than an XML file? The reason I ask this is, that each function I said the home screen is made up of, title, user details, balance etc, I have an activity for each of these. Each of these functions has custom functionality that I have designed, such as animation etc. If I simply inflate these xml files, then I can't access the widgets inside so I can't set up the functionality from Java which is what I need.</p>

<p>If I was able to inflate another activity, then this would not be a problem, as I would set up the functionality for each function in activity, then just inflate that class.</p>

<p>I hope my question was clear, if not I can expand on any areas you are not sure about.</p>

<p>Would be very grateful for any assistance!!</p>

<p>EDIT: If it is not possible to inflate a class, then is there any other way method you could recommend that could solve my problem?</p>
