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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:41:33+00:00 2026-05-23T16:41:33+00:00

My main.xml layout simply contains a button and a LinearLayout content_area , which shows

  • 0

My main.xml layout simply contains a button and a LinearLayout content_area, which shows below:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">


    <LinearLayout 
        android:id="@+id/myBtns"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
    >
        <Button
            android:id="@+id/btn_one"
            android:layout_width="100dip"
            android:layout_height="30dip"
                android:text="button one"
         />

    </LinearLayout>

    <LinearLayout 
        android:id="@+id/content_area"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
    >
         <!--inflate layout here-->

    </LinearLayout>


   </LinearLayout>

I have another layout (content_one.xml) which is going to be used to embed(inflate) to content_area(id value) of the main.xml layout:

content_one.xml:

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <TextView.../>
         ... 
        <Button .../>

    </LinearLayout>

I tried to use LayoutInflater to embed content_one.xml into content_area of main.xml:

public class MyActivity extends Activity{

      private LinearLayout contentArea;

      @Override
      public void onCreate(Bundle savedInstanceState) {

              super.onCreate(savedInstanceState);
              setContentView(R.layout.main);

              contentArea= (LinearLayout) findViewById(R.id.content_area);

              LayoutInflater inflater = (LayoutInflater)MyActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View inflatedView = (View) inflater.inflate(R.layout.content_one, null);

              contentArea.addView(inflatedView);
}

But it does not work, content_one.xml does not show in content_area of main.xml . I got the following error message from LogCat in eclipse

(Please mouse right click on the following image and view image)

enter image description here

why my LayoutInflater is not working? Where am I wrong?

  • 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-23T16:41:34+00:00Added an answer on May 23, 2026 at 4:41 pm

    The View inflates correctly, but you have a fill_parent height on the myBtns layout, so the other LinearLayout is not visible. If you change it to wrap_content you can see the other LinearLayout.

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

Sidebar

Related Questions

I have a basic Android question here: I have a main.xml layout that loads
Here is my simple example. I defined a button in main.xml file, and 'on
I'm trying to set the URL for a WebView from the layout main.xml. By
How can I change the font size in a ListView element? In my main.xml
import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button;
I have an XML layout with some custom tabs, a heading, and a ProgressBar
I have a main menu screen with a simple ListView that contains links to
I just started messing with android dev and I am trying to simply play
I have one spinner in which few values are there from strings.xml and I
Hello all this is my code for the tab layout in to android i

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.